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
21 #include "wine/port.h"
22 #define NONAMELESSUNION
23 #include "wine/debug.h"
24 #include "wine/unicode.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
;
85 enum SHADER_CONSTANT_TYPE
102 struct d3dx_parameter
107 D3DXPARAMETER_CLASS
class;
108 D3DXPARAMETER_TYPE type
;
112 UINT annotation_count
;
117 D3DXHANDLE
*annotation_handles
;
118 D3DXHANDLE
*member_handles
;
125 enum STATE_TYPE type
;
126 D3DXHANDLE parameter
;
132 struct d3dx_state
*states
;
139 UINT annotation_count
;
141 struct d3dx_state
*states
;
142 D3DXHANDLE
*annotation_handles
;
145 struct d3dx_technique
149 UINT annotation_count
;
151 D3DXHANDLE
*annotation_handles
;
152 D3DXHANDLE
*pass_handles
;
155 struct ID3DXBaseEffectImpl
157 ID3DXBaseEffect ID3DXBaseEffect_iface
;
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
;
174 LPD3DXEFFECTSTATEMANAGER manager
;
175 LPDIRECT3DDEVICE9 device
;
176 LPD3DXEFFECTPOOL pool
;
177 D3DXHANDLE active_technique
;
178 D3DXHANDLE active_pass
;
180 ID3DXBaseEffect
*base_effect
;
183 struct ID3DXEffectCompilerImpl
185 ID3DXEffectCompiler ID3DXEffectCompiler_iface
;
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
);
199 enum STATE_CLASS
class;
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"},
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"},
329 {SC_NPATCHMODE
, 0, "NPatchMode"},
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"},
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"},
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 */
358 {SC_LIGHTENABLE
, 0, "LightEnable"},
360 {SC_VERTEXSHADER
, 0, "Vertexshader"},
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"},
381 {SC_TEXTURE
, 0, "Texture"},
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"},
397 {SC_SETSAMPLER
, 0, "Sampler"},
400 static inline void read_dword(const char **ptr
, DWORD
*d
)
402 memcpy(d
, *ptr
, sizeof(*d
));
406 static void skip_dword_unknown(const char **ptr
, unsigned int count
)
411 FIXME("Skipping %u unknown DWORDs:\n", count
);
412 for (i
= 0; i
< count
; ++i
)
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
)
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
))
461 TRACE("Returning technique %p\n", tech
);
469 static struct d3dx_technique
*is_valid_technique(struct ID3DXBaseEffectImpl
*base
, D3DXHANDLE technique
)
471 struct d3dx_technique
*tech
= NULL
;
474 for (i
= 0; i
< base
->technique_count
; ++i
)
476 if (base
->technique_handles
[i
] == technique
)
478 tech
= get_technique_struct(technique
);
483 if (!tech
) tech
= get_technique_by_name(base
, technique
);
488 static struct d3dx_pass
*is_valid_pass(struct ID3DXBaseEffectImpl
*base
, D3DXHANDLE pass
)
492 for (i
= 0; i
< base
->technique_count
; ++i
)
494 struct d3dx_technique
*technique
= get_technique_struct(base
->technique_handles
[i
]);
496 for (k
= 0; k
< technique
->pass_count
; ++k
)
498 if (technique
->pass_handles
[k
] == pass
)
500 return get_pass_struct(pass
);
508 static struct d3dx_parameter
*is_valid_sub_parameter(struct d3dx_parameter
*param
, D3DXHANDLE parameter
)
510 unsigned int i
, count
;
511 struct d3dx_parameter
*p
;
513 for (i
= 0; i
< param
->annotation_count
; ++i
)
515 if (param
->annotation_handles
[i
] == parameter
)
517 return get_parameter_struct(parameter
);
520 p
= is_valid_sub_parameter(get_parameter_struct(param
->annotation_handles
[i
]), parameter
);
524 if (param
->element_count
) count
= param
->element_count
;
525 else count
= param
->member_count
;
527 for (i
= 0; i
< count
; ++i
)
529 if (param
->member_handles
[i
] == parameter
)
531 return get_parameter_struct(parameter
);
534 p
= is_valid_sub_parameter(get_parameter_struct(param
->member_handles
[i
]), parameter
);
541 static struct d3dx_parameter
*is_valid_parameter(struct ID3DXBaseEffectImpl
*base
, D3DXHANDLE parameter
)
543 unsigned int i
, k
, m
;
544 struct d3dx_parameter
*p
;
546 for (i
= 0; i
< base
->parameter_count
; ++i
)
548 if (base
->parameter_handles
[i
] == parameter
)
550 return get_parameter_struct(parameter
);
553 p
= is_valid_sub_parameter(get_parameter_struct(base
->parameter_handles
[i
]), parameter
);
557 for (i
= 0; i
< base
->technique_count
; ++i
)
559 struct d3dx_technique
*technique
= get_technique_struct(base
->technique_handles
[i
]);
561 for (k
= 0; k
< technique
->pass_count
; ++k
)
563 struct d3dx_pass
*pass
= get_pass_struct(technique
->pass_handles
[k
]);
565 for (m
= 0; m
< pass
->annotation_count
; ++m
)
567 if (pass
->annotation_handles
[i
] == parameter
)
569 return get_parameter_struct(parameter
);
572 p
= is_valid_sub_parameter(get_parameter_struct(pass
->annotation_handles
[m
]), parameter
);
577 for (k
= 0; k
< technique
->annotation_count
; ++k
)
579 if (technique
->annotation_handles
[k
] == parameter
)
581 return get_parameter_struct(parameter
);
584 p
= is_valid_sub_parameter(get_parameter_struct(technique
->annotation_handles
[k
]), parameter
);
592 static inline struct d3dx_parameter
*get_valid_parameter(struct ID3DXBaseEffectImpl
*base
, D3DXHANDLE parameter
)
594 struct d3dx_parameter
*param
= is_valid_parameter(base
, parameter
);
596 if (!param
) param
= get_parameter_by_name(base
, NULL
, parameter
);
601 static void free_state(struct d3dx_state
*state
)
603 free_parameter_state(state
->parameter
, FALSE
, FALSE
, state
->type
);
606 static void free_sampler(struct d3dx_sampler
*sampler
)
610 for (i
= 0; i
< sampler
->state_count
; ++i
)
612 free_state(&sampler
->states
[i
]);
614 HeapFree(GetProcessHeap(), 0, sampler
->states
);
617 static void free_parameter(D3DXHANDLE handle
, BOOL element
, BOOL child
)
619 free_parameter_state(handle
, element
, child
, ST_CONSTANT
);
622 static void free_parameter_state(D3DXHANDLE handle
, BOOL element
, BOOL child
, enum STATE_TYPE st
)
625 struct d3dx_parameter
*param
= get_parameter_struct(handle
);
627 TRACE("Free parameter %p, name %s, type %s, child %s, state_type %x\n", param
, param
->name
,
628 debug_d3dxparameter_type(param
->type
), child
? "yes" : "no", st
);
635 if (param
->annotation_handles
)
637 for (i
= 0; i
< param
->annotation_count
; ++i
)
639 free_parameter(param
->annotation_handles
[i
], FALSE
, FALSE
);
641 HeapFree(GetProcessHeap(), 0, param
->annotation_handles
);
644 if (param
->member_handles
)
648 if (param
->element_count
) count
= param
->element_count
;
649 else count
= param
->member_count
;
651 for (i
= 0; i
< count
; ++i
)
653 free_parameter(param
->member_handles
[i
], param
->element_count
!= 0, TRUE
);
655 HeapFree(GetProcessHeap(), 0, param
->member_handles
);
658 if (param
->class == D3DXPC_OBJECT
&& !param
->element_count
)
663 HeapFree(GetProcessHeap(), 0, *(LPSTR
*)param
->data
);
664 if (!child
) HeapFree(GetProcessHeap(), 0, param
->data
);
668 case D3DXPT_TEXTURE1D
:
669 case D3DXPT_TEXTURE2D
:
670 case D3DXPT_TEXTURE3D
:
671 case D3DXPT_TEXTURECUBE
:
672 case D3DXPT_PIXELSHADER
:
673 case D3DXPT_VERTEXSHADER
:
674 if (st
== ST_CONSTANT
)
676 if (*(IUnknown
**)param
->data
) IUnknown_Release(*(IUnknown
**)param
->data
);
680 HeapFree(GetProcessHeap(), 0, *(LPSTR
*)param
->data
);
682 if (!child
) HeapFree(GetProcessHeap(), 0, param
->data
);
686 case D3DXPT_SAMPLER1D
:
687 case D3DXPT_SAMPLER2D
:
688 case D3DXPT_SAMPLER3D
:
689 case D3DXPT_SAMPLERCUBE
:
690 if (st
== ST_CONSTANT
)
692 free_sampler((struct d3dx_sampler
*)param
->data
);
696 HeapFree(GetProcessHeap(), 0, *(LPSTR
*)param
->data
);
698 /* samplers have always own data, so free that */
699 HeapFree(GetProcessHeap(), 0, param
->data
);
703 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
711 if (st
!= ST_CONSTANT
)
713 HeapFree(GetProcessHeap(), 0, *(LPSTR
*)param
->data
);
715 HeapFree(GetProcessHeap(), 0, param
->data
);
719 /* only the parent has to release name and semantic */
722 HeapFree(GetProcessHeap(), 0, param
->name
);
723 HeapFree(GetProcessHeap(), 0, param
->semantic
);
726 HeapFree(GetProcessHeap(), 0, param
);
729 static void free_pass(D3DXHANDLE handle
)
732 struct d3dx_pass
*pass
= get_pass_struct(handle
);
734 TRACE("Free pass %p\n", pass
);
741 if (pass
->annotation_handles
)
743 for (i
= 0; i
< pass
->annotation_count
; ++i
)
745 free_parameter(pass
->annotation_handles
[i
], FALSE
, FALSE
);
747 HeapFree(GetProcessHeap(), 0, pass
->annotation_handles
);
752 for (i
= 0; i
< pass
->state_count
; ++i
)
754 free_state(&pass
->states
[i
]);
756 HeapFree(GetProcessHeap(), 0, pass
->states
);
759 HeapFree(GetProcessHeap(), 0, pass
->name
);
760 HeapFree(GetProcessHeap(), 0, pass
);
763 static void free_technique(D3DXHANDLE handle
)
766 struct d3dx_technique
*technique
= get_technique_struct(handle
);
768 TRACE("Free technique %p\n", technique
);
775 if (technique
->annotation_handles
)
777 for (i
= 0; i
< technique
->annotation_count
; ++i
)
779 free_parameter(technique
->annotation_handles
[i
], FALSE
, FALSE
);
781 HeapFree(GetProcessHeap(), 0, technique
->annotation_handles
);
784 if (technique
->pass_handles
)
786 for (i
= 0; i
< technique
->pass_count
; ++i
)
788 free_pass(technique
->pass_handles
[i
]);
790 HeapFree(GetProcessHeap(), 0, technique
->pass_handles
);
793 HeapFree(GetProcessHeap(), 0, technique
->name
);
794 HeapFree(GetProcessHeap(), 0, technique
);
797 static void free_base_effect(struct ID3DXBaseEffectImpl
*base
)
801 TRACE("Free base effect %p\n", base
);
803 if (base
->parameter_handles
)
805 for (i
= 0; i
< base
->parameter_count
; ++i
)
807 free_parameter(base
->parameter_handles
[i
], FALSE
, FALSE
);
809 HeapFree(GetProcessHeap(), 0, base
->parameter_handles
);
812 if (base
->technique_handles
)
814 for (i
= 0; i
< base
->technique_count
; ++i
)
816 free_technique(base
->technique_handles
[i
]);
818 HeapFree(GetProcessHeap(), 0, base
->technique_handles
);
822 static void free_effect(struct ID3DXEffectImpl
*effect
)
824 TRACE("Free effect %p\n", effect
);
826 if (effect
->base_effect
)
828 effect
->base_effect
->lpVtbl
->Release(effect
->base_effect
);
833 effect
->pool
->lpVtbl
->Release(effect
->pool
);
838 IUnknown_Release(effect
->manager
);
841 IDirect3DDevice9_Release(effect
->device
);
844 static void free_effect_compiler(struct ID3DXEffectCompilerImpl
*compiler
)
846 TRACE("Free effect compiler %p\n", compiler
);
848 if (compiler
->base_effect
)
850 compiler
->base_effect
->lpVtbl
->Release(compiler
->base_effect
);
854 static INT
get_int(D3DXPARAMETER_TYPE type
, LPCVOID data
)
874 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type
));
881 inline static FLOAT
get_float(D3DXPARAMETER_TYPE type
, LPCVOID data
)
901 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type
));
908 static inline BOOL
get_bool(LPCVOID data
)
910 return (*(DWORD
*)data
) ? TRUE
: FALSE
;
913 static void set_number(LPVOID outdata
, D3DXPARAMETER_TYPE outtype
, LPCVOID indata
, D3DXPARAMETER_TYPE intype
)
915 TRACE("Changing from type %i to type %i\n", intype
, outtype
);
920 *(FLOAT
*)outdata
= get_float(intype
, indata
);
924 *(BOOL
*)outdata
= get_bool(indata
);
928 *(INT
*)outdata
= get_int(intype
, indata
);
932 FIXME("Error converting to type %i\n", outtype
);
938 static void get_vector(struct d3dx_parameter
*param
, D3DXVECTOR4
*vector
)
942 for (i
= 0; i
< 4; ++i
)
944 ((FLOAT
*)vector
)[i
] = i
< param
->columns
? get_float(param
->type
, (DWORD
*)param
->data
+ i
) : 0.0f
;
948 static void set_vector(struct d3dx_parameter
*param
, CONST D3DXVECTOR4
*vector
)
952 for (i
= 0; i
< param
->columns
; ++i
)
954 set_number((FLOAT
*)param
->data
+ i
, param
->type
, (FLOAT
*)vector
+ i
, D3DXPT_FLOAT
);
958 static void get_matrix(struct d3dx_parameter
*param
, D3DXMATRIX
*matrix
)
962 for (i
= 0; i
< 4; ++i
)
964 for (k
= 0; k
< 4; ++k
)
966 if ((i
< param
->rows
) && (k
< param
->columns
))
967 matrix
->u
.m
[i
][k
] = get_float(param
->type
, (FLOAT
*)param
->data
+ i
* param
->columns
+ k
);
969 matrix
->u
.m
[i
][k
] = 0.0f
;
974 static void set_matrix(struct d3dx_parameter
*param
, CONST D3DXMATRIX
*matrix
)
978 for (i
= 0; i
< 4; ++i
)
980 for (k
= 0; k
< 4; ++k
)
982 if ((i
< param
->rows
) && (k
< param
->columns
))
983 set_number((FLOAT
*)param
->data
+ i
* param
->columns
+ k
, param
->type
, &matrix
->u
.m
[i
][k
], D3DXPT_FLOAT
);
988 static struct d3dx_parameter
*get_parameter_element_by_name(struct d3dx_parameter
*parameter
, LPCSTR name
)
991 struct d3dx_parameter
*temp_parameter
;
994 TRACE("parameter %p, name %s\n", parameter
, debugstr_a(name
));
996 if (!name
|| !*name
) return NULL
;
998 element
= atoi(name
);
999 part
= strchr(name
, ']') + 1;
1001 /* check for empty [] && element range */
1002 if ((part
- name
) > 1 && parameter
->element_count
> element
)
1004 temp_parameter
= get_parameter_struct(parameter
->member_handles
[element
]);
1009 return get_parameter_by_name(NULL
, temp_parameter
, part
);
1012 return get_annotation_by_name(temp_parameter
->annotation_count
, temp_parameter
->annotation_handles
, part
);
1015 TRACE("Returning parameter %p\n", temp_parameter
);
1016 return temp_parameter
;
1019 FIXME("Unhandled case \"%c\"\n", *--part
);
1024 TRACE("Parameter not found\n");
1028 static struct d3dx_parameter
*get_annotation_by_name(UINT handlecount
, D3DXHANDLE
*handles
, LPCSTR name
)
1031 struct d3dx_parameter
*temp_parameter
;
1034 TRACE("handlecount %u, handles %p, name %s\n", handlecount
, handles
, debugstr_a(name
));
1036 if (!name
|| !*name
) return NULL
;
1038 length
= strcspn( name
, "[.@" );
1039 part
= name
+ length
;
1041 for (i
= 0; i
< handlecount
; ++i
)
1043 temp_parameter
= get_parameter_struct(handles
[i
]);
1045 if (!strcmp(temp_parameter
->name
, name
))
1047 TRACE("Returning parameter %p\n", temp_parameter
);
1048 return temp_parameter
;
1050 else if (strlen(temp_parameter
->name
) == length
&& !strncmp(temp_parameter
->name
, name
, length
))
1055 return get_parameter_by_name(NULL
, temp_parameter
, part
);
1058 return get_parameter_element_by_name(temp_parameter
, part
);
1061 FIXME("Unhandled case \"%c\"\n", *--part
);
1067 TRACE("Parameter not found\n");
1071 static struct d3dx_parameter
*get_parameter_by_name(struct ID3DXBaseEffectImpl
*base
,
1072 struct d3dx_parameter
*parameter
, LPCSTR name
)
1074 UINT i
, count
, length
;
1075 struct d3dx_parameter
*temp_parameter
;
1076 D3DXHANDLE
*handles
;
1079 TRACE("base %p, parameter %p, name %s\n", base
, parameter
, debugstr_a(name
));
1081 if (!name
|| !*name
) return NULL
;
1085 count
= base
->parameter_count
;
1086 handles
= base
->parameter_handles
;
1090 count
= parameter
->member_count
;
1091 handles
= parameter
->member_handles
;
1094 length
= strcspn( name
, "[.@" );
1095 part
= name
+ length
;
1097 for (i
= 0; i
< count
; i
++)
1099 temp_parameter
= get_parameter_struct(handles
[i
]);
1101 if (!strcmp(temp_parameter
->name
, name
))
1103 TRACE("Returning parameter %p\n", temp_parameter
);
1104 return temp_parameter
;
1106 else if (strlen(temp_parameter
->name
) == length
&& !strncmp(temp_parameter
->name
, name
, length
))
1111 return get_parameter_by_name(NULL
, temp_parameter
, part
);
1114 return get_annotation_by_name(temp_parameter
->annotation_count
, temp_parameter
->annotation_handles
, part
);
1117 return get_parameter_element_by_name(temp_parameter
, part
);
1120 FIXME("Unhandled case \"%c\"\n", *--part
);
1126 TRACE("Parameter not found\n");
1130 static inline DWORD
d3dx9_effect_version(DWORD major
, DWORD minor
)
1132 return (0xfeff0000 | ((major
) << 8) | (minor
));
1135 static inline struct ID3DXBaseEffectImpl
*impl_from_ID3DXBaseEffect(ID3DXBaseEffect
*iface
)
1137 return CONTAINING_RECORD(iface
, struct ID3DXBaseEffectImpl
, ID3DXBaseEffect_iface
);
1140 /*** IUnknown methods ***/
1141 static HRESULT WINAPI
ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect
*iface
, REFIID riid
, void **object
)
1143 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), object
);
1145 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
1146 IsEqualGUID(riid
, &IID_ID3DXBaseEffect
))
1148 iface
->lpVtbl
->AddRef(iface
);
1153 ERR("Interface %s not found\n", debugstr_guid(riid
));
1155 return E_NOINTERFACE
;
1158 static ULONG WINAPI
ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect
*iface
)
1160 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1162 TRACE("iface %p: AddRef from %u\n", iface
, This
->ref
);
1164 return InterlockedIncrement(&This
->ref
);
1167 static ULONG WINAPI
ID3DXBaseEffectImpl_Release(ID3DXBaseEffect
*iface
)
1169 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1170 ULONG ref
= InterlockedDecrement(&This
->ref
);
1172 TRACE("iface %p: Release from %u\n", iface
, ref
+ 1);
1176 free_base_effect(This
);
1177 HeapFree(GetProcessHeap(), 0, This
);
1183 /*** ID3DXBaseEffect methods ***/
1184 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect
*iface
, D3DXEFFECT_DESC
*desc
)
1186 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1188 FIXME("iface %p, desc %p partial stub\n", This
, desc
);
1192 WARN("Invalid argument specified.\n");
1193 return D3DERR_INVALIDCALL
;
1196 /* Todo: add creator and function count */
1197 desc
->Creator
= NULL
;
1198 desc
->Functions
= 0;
1199 desc
->Parameters
= This
->parameter_count
;
1200 desc
->Techniques
= This
->technique_count
;
1205 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, D3DXPARAMETER_DESC
*desc
)
1207 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1208 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1210 TRACE("iface %p, parameter %p, desc %p\n", This
, parameter
, desc
);
1212 if (!desc
|| !param
)
1214 WARN("Invalid argument specified.\n");
1215 return D3DERR_INVALIDCALL
;
1218 desc
->Name
= param
->name
;
1219 desc
->Semantic
= param
->semantic
;
1220 desc
->Class
= param
->class;
1221 desc
->Type
= param
->type
;
1222 desc
->Rows
= param
->rows
;
1223 desc
->Columns
= param
->columns
;
1224 desc
->Elements
= param
->element_count
;
1225 desc
->Annotations
= param
->annotation_count
;
1226 desc
->StructMembers
= param
->member_count
;
1227 desc
->Flags
= param
->flags
;
1228 desc
->Bytes
= param
->bytes
;
1233 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect
*iface
, D3DXHANDLE technique
, D3DXTECHNIQUE_DESC
*desc
)
1235 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1236 struct d3dx_technique
*tech
= technique
? is_valid_technique(This
, technique
) : get_technique_struct(This
->technique_handles
[0]);
1238 TRACE("iface %p, technique %p, desc %p\n", This
, technique
, desc
);
1242 WARN("Invalid argument specified.\n");
1243 return D3DERR_INVALIDCALL
;
1246 desc
->Name
= tech
->name
;
1247 desc
->Passes
= tech
->pass_count
;
1248 desc
->Annotations
= tech
->annotation_count
;
1253 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect
*iface
, D3DXHANDLE pass
, D3DXPASS_DESC
*desc
)
1255 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1256 struct d3dx_pass
*p
= is_valid_pass(This
, pass
);
1258 TRACE("iface %p, pass %p, desc %p\n", This
, pass
, desc
);
1262 WARN("Invalid argument specified.\n");
1263 return D3DERR_INVALIDCALL
;
1266 desc
->Name
= p
->name
;
1267 desc
->Annotations
= p
->annotation_count
;
1269 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1270 desc
->pVertexShaderFunction
= NULL
;
1271 desc
->pPixelShaderFunction
= NULL
;
1276 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect
*iface
, D3DXHANDLE shader
, D3DXFUNCTION_DESC
*desc
)
1278 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1280 FIXME("iface %p, shader %p, desc %p stub\n", This
, shader
, desc
);
1285 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, UINT index
)
1287 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1288 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1290 TRACE("iface %p, parameter %p, index %u\n", This
, parameter
, index
);
1294 if (index
< This
->parameter_count
)
1296 TRACE("Returning parameter %p\n", This
->parameter_handles
[index
]);
1297 return This
->parameter_handles
[index
];
1302 if (param
&& !param
->element_count
&& index
< param
->member_count
)
1304 TRACE("Returning parameter %p\n", param
->member_handles
[index
]);
1305 return param
->member_handles
[index
];
1309 WARN("Invalid argument specified.\n");
1314 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPCSTR name
)
1316 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1317 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1320 TRACE("iface %p, parameter %p, name %s\n", This
, parameter
, debugstr_a(name
));
1324 handle
= get_parameter_handle(param
);
1325 TRACE("Returning parameter %p\n", handle
);
1329 handle
= get_parameter_handle(get_parameter_by_name(This
, param
, name
));
1330 TRACE("Returning parameter %p\n", handle
);
1335 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPCSTR semantic
)
1337 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1338 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1339 struct d3dx_parameter
*temp_param
;
1342 TRACE("iface %p, parameter %p, semantic %s\n", This
, parameter
, debugstr_a(semantic
));
1346 for (i
= 0; i
< This
->parameter_count
; ++i
)
1348 temp_param
= get_parameter_struct(This
->parameter_handles
[i
]);
1350 if (!temp_param
->semantic
)
1354 TRACE("Returning parameter %p\n", This
->parameter_handles
[i
]);
1355 return This
->parameter_handles
[i
];
1360 if (!strcasecmp(temp_param
->semantic
, semantic
))
1362 TRACE("Returning parameter %p\n", This
->parameter_handles
[i
]);
1363 return This
->parameter_handles
[i
];
1369 for (i
= 0; i
< param
->member_count
; ++i
)
1371 temp_param
= get_parameter_struct(param
->member_handles
[i
]);
1373 if (!temp_param
->semantic
)
1377 TRACE("Returning parameter %p\n", param
->member_handles
[i
]);
1378 return param
->member_handles
[i
];
1383 if (!strcasecmp(temp_param
->semantic
, semantic
))
1385 TRACE("Returning parameter %p\n", param
->member_handles
[i
]);
1386 return param
->member_handles
[i
];
1391 WARN("Invalid argument specified\n");
1396 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, UINT index
)
1398 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1399 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1401 TRACE("iface %p, parameter %p, index %u\n", This
, parameter
, index
);
1405 if (index
< This
->parameter_count
)
1407 TRACE("Returning parameter %p\n", This
->parameter_handles
[index
]);
1408 return This
->parameter_handles
[index
];
1413 if (index
< param
->element_count
)
1415 TRACE("Returning parameter %p\n", param
->member_handles
[index
]);
1416 return param
->member_handles
[index
];
1420 WARN("Invalid argument specified\n");
1425 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect
*iface
, UINT index
)
1427 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1429 TRACE("iface %p, index %u\n", This
, index
);
1431 if (index
>= This
->technique_count
)
1433 WARN("Invalid argument specified.\n");
1437 TRACE("Returning technique %p\n", This
->technique_handles
[index
]);
1439 return This
->technique_handles
[index
];
1442 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect
*iface
, LPCSTR name
)
1444 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1445 struct d3dx_technique
*tech
= get_technique_by_name(This
, name
);
1447 TRACE("iface %p, name %s stub\n", This
, debugstr_a(name
));
1451 D3DXHANDLE t
= get_technique_handle(tech
);
1452 TRACE("Returning technique %p\n", t
);
1456 WARN("Invalid argument specified.\n");
1461 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect
*iface
, D3DXHANDLE technique
, UINT index
)
1463 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1464 struct d3dx_technique
*tech
= is_valid_technique(This
, technique
);
1466 TRACE("iface %p, technique %p, index %u\n", This
, technique
, index
);
1468 if (tech
&& index
< tech
->pass_count
)
1470 TRACE("Returning pass %p\n", tech
->pass_handles
[index
]);
1471 return tech
->pass_handles
[index
];
1474 WARN("Invalid argument specified.\n");
1479 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect
*iface
, D3DXHANDLE technique
, LPCSTR name
)
1481 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1482 struct d3dx_technique
*tech
= is_valid_technique(This
, technique
);
1484 TRACE("iface %p, technique %p, name %s\n", This
, technique
, debugstr_a(name
));
1490 for (i
= 0; i
< tech
->pass_count
; ++i
)
1492 struct d3dx_pass
*pass
= get_pass_struct(tech
->pass_handles
[i
]);
1494 if (!strcmp(pass
->name
, name
))
1496 TRACE("Returning pass %p\n", tech
->pass_handles
[i
]);
1497 return tech
->pass_handles
[i
];
1502 WARN("Invalid argument specified.\n");
1507 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect
*iface
, UINT index
)
1509 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1511 FIXME("iface %p, index %u stub\n", This
, index
);
1516 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect
*iface
, LPCSTR name
)
1518 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1520 FIXME("iface %p, name %s stub\n", This
, debugstr_a(name
));
1525 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect
*iface
, D3DXHANDLE object
, UINT index
)
1527 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1528 struct d3dx_parameter
*param
= get_valid_parameter(This
, object
);
1529 struct d3dx_pass
*pass
= is_valid_pass(This
, object
);
1530 struct d3dx_technique
*technique
= is_valid_technique(This
, object
);
1531 UINT annotation_count
= 0;
1532 D3DXHANDLE
*annotation_handles
= NULL
;
1534 TRACE("iface %p, object %p, index %u\n", This
, object
, index
);
1538 annotation_count
= pass
->annotation_count
;
1539 annotation_handles
= pass
->annotation_handles
;
1543 annotation_count
= technique
->annotation_count
;
1544 annotation_handles
= technique
->annotation_handles
;
1548 annotation_count
= param
->annotation_count
;
1549 annotation_handles
= param
->annotation_handles
;
1553 FIXME("Functions are not handled, yet!\n");
1556 if (index
< annotation_count
)
1558 TRACE("Returning parameter %p\n", annotation_handles
[index
]);
1559 return annotation_handles
[index
];
1562 WARN("Invalid argument specified\n");
1567 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect
*iface
, D3DXHANDLE object
, LPCSTR name
)
1569 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1570 struct d3dx_parameter
*param
= get_valid_parameter(This
, object
);
1571 struct d3dx_pass
*pass
= is_valid_pass(This
, object
);
1572 struct d3dx_technique
*technique
= is_valid_technique(This
, object
);
1573 struct d3dx_parameter
*anno
= NULL
;
1574 UINT annotation_count
= 0;
1575 D3DXHANDLE
*annotation_handles
= NULL
;
1577 TRACE("iface %p, object %p, name %s\n", This
, object
, debugstr_a(name
));
1581 WARN("Invalid argument specified\n");
1587 annotation_count
= pass
->annotation_count
;
1588 annotation_handles
= pass
->annotation_handles
;
1592 annotation_count
= technique
->annotation_count
;
1593 annotation_handles
= technique
->annotation_handles
;
1597 annotation_count
= param
->annotation_count
;
1598 annotation_handles
= param
->annotation_handles
;
1602 FIXME("Functions are not handled, yet!\n");
1605 anno
= get_annotation_by_name(annotation_count
, annotation_handles
, name
);
1608 TRACE("Returning parameter %p\n", anno
);
1609 return get_parameter_handle(anno
);
1612 WARN("Invalid argument specified\n");
1617 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPCVOID data
, UINT bytes
)
1619 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1620 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1622 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This
, parameter
, data
, bytes
);
1626 WARN("Invalid parameter %p specified\n", parameter
);
1627 return D3DERR_INVALIDCALL
;
1630 /* samplers don't touch data */
1631 if (param
->class == D3DXPC_OBJECT
&& (param
->type
== D3DXPT_SAMPLER
1632 || param
->type
== D3DXPT_SAMPLER1D
|| param
->type
== D3DXPT_SAMPLER2D
1633 || param
->type
== D3DXPT_SAMPLER3D
|| param
->type
== D3DXPT_SAMPLERCUBE
))
1635 TRACE("Sampler: returning E_FAIL\n");
1639 if (data
&& param
->bytes
<= bytes
)
1641 switch (param
->type
)
1647 TRACE("Copy %u bytes\n", param
->bytes
);
1648 memcpy(param
->data
, data
, param
->bytes
);
1652 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
1659 WARN("Invalid argument specified\n");
1661 return D3DERR_INVALIDCALL
;
1664 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPVOID data
, UINT bytes
)
1666 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1667 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1669 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This
, parameter
, data
, bytes
);
1673 WARN("Invalid parameter %p specified\n", parameter
);
1674 return D3DERR_INVALIDCALL
;
1677 /* samplers don't touch data */
1678 if (param
->class == D3DXPC_OBJECT
&& (param
->type
== D3DXPT_SAMPLER
1679 || param
->type
== D3DXPT_SAMPLER1D
|| param
->type
== D3DXPT_SAMPLER2D
1680 || param
->type
== D3DXPT_SAMPLER3D
|| param
->type
== D3DXPT_SAMPLERCUBE
))
1682 TRACE("Sampler: returning E_FAIL\n");
1686 if (data
&& param
->bytes
<= bytes
)
1688 TRACE("Type %s\n", debug_d3dxparameter_type(param
->type
));
1690 switch (param
->type
)
1699 case D3DXPT_VERTEXSHADER
:
1700 case D3DXPT_PIXELSHADER
:
1701 case D3DXPT_TEXTURE
:
1702 case D3DXPT_TEXTURE1D
:
1703 case D3DXPT_TEXTURE2D
:
1704 case D3DXPT_TEXTURE3D
:
1705 case D3DXPT_TEXTURECUBE
:
1709 for (i
= 0; i
< (param
->element_count
? param
->element_count
: 1); ++i
)
1711 IUnknown
*unk
= ((IUnknown
**)param
->data
)[i
];
1712 if (unk
) IUnknown_AddRef(unk
);
1718 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
1722 TRACE("Copy %u bytes\n", param
->bytes
);
1723 memcpy(data
, param
->data
, param
->bytes
);
1727 WARN("Invalid argument specified\n");
1729 return D3DERR_INVALIDCALL
;
1732 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, BOOL b
)
1734 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1735 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1737 TRACE("iface %p, parameter %p, b %s\n", This
, parameter
, b
? "TRUE" : "FALSE");
1739 if (param
&& !param
->element_count
&& param
->rows
== 1 && param
->columns
== 1)
1742 b
= b
? TRUE
: FALSE
;
1743 set_number(param
->data
, param
->type
, &b
, D3DXPT_BOOL
);
1747 WARN("Invalid argument specified\n");
1749 return D3DERR_INVALIDCALL
;
1752 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, BOOL
*b
)
1754 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1755 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1757 TRACE("iface %p, parameter %p, b %p\n", This
, parameter
, b
);
1759 if (b
&& param
&& !param
->element_count
&& param
->rows
== 1 && param
->columns
== 1)
1761 *b
= get_bool(param
->data
);
1762 TRACE("Returning %s\n", *b
? "TRUE" : "FALSE");
1766 WARN("Invalid argument specified\n");
1768 return D3DERR_INVALIDCALL
;
1771 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST BOOL
*b
, UINT count
)
1773 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1774 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1776 TRACE("iface %p, parameter %p, b %p, count %u\n", This
, parameter
, b
, count
);
1780 UINT i
, size
= min(count
, param
->bytes
/ sizeof(DWORD
));
1782 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
1784 switch (param
->class)
1788 case D3DXPC_MATRIX_ROWS
:
1789 for (i
= 0; i
< size
; ++i
)
1791 set_number((DWORD
*)param
->data
+ i
, param
->type
, &b
[i
], D3DXPT_BOOL
);
1800 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
1805 WARN("Invalid argument specified\n");
1807 return D3DERR_INVALIDCALL
;
1810 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, BOOL
*b
, UINT count
)
1812 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1813 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1815 TRACE("iface %p, parameter %p, b %p, count %u\n", This
, parameter
, b
, count
);
1817 if (b
&& param
&& (param
->class == D3DXPC_SCALAR
1818 || param
->class == D3DXPC_VECTOR
1819 || param
->class == D3DXPC_MATRIX_ROWS
1820 || param
->class == D3DXPC_MATRIX_COLUMNS
))
1822 UINT i
, size
= min(count
, param
->bytes
/ sizeof(DWORD
));
1824 for (i
= 0; i
< size
; ++i
)
1826 b
[i
] = get_bool((DWORD
*)param
->data
+ i
);
1831 WARN("Invalid argument specified\n");
1833 return D3DERR_INVALIDCALL
;
1836 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, INT n
)
1838 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1839 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1841 TRACE("iface %p, parameter %p, n %i\n", This
, parameter
, n
);
1843 if (param
&& !param
->element_count
)
1845 if (param
->rows
== 1 && param
->columns
== 1)
1847 set_number(param
->data
, param
->type
, &n
, D3DXPT_INT
);
1852 * Split the value, if parameter is a vector with dimension 3 or 4.
1854 if (param
->type
== D3DXPT_FLOAT
&&
1855 ((param
->class == D3DXPC_VECTOR
&& param
->columns
!= 2) ||
1856 (param
->class == D3DXPC_MATRIX_ROWS
&& param
->rows
!= 2 && param
->columns
== 1)))
1858 TRACE("Vector fixup\n");
1860 *(FLOAT
*)param
->data
= ((n
& 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE
;
1861 ((FLOAT
*)param
->data
)[1] = ((n
& 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE
;
1862 ((FLOAT
*)param
->data
)[2] = (n
& 0xff) * INT_FLOAT_MULTI_INVERSE
;
1863 if (param
->rows
* param
->columns
> 3)
1865 ((FLOAT
*)param
->data
)[3] = ((n
& 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE
;
1871 WARN("Invalid argument specified\n");
1873 return D3DERR_INVALIDCALL
;
1876 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, INT
*n
)
1878 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1879 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1881 TRACE("iface %p, parameter %p, n %p\n", This
, parameter
, n
);
1883 if (n
&& param
&& !param
->element_count
)
1885 if (param
->columns
== 1 && param
->rows
== 1)
1887 *n
= get_int(param
->type
, param
->data
);
1888 TRACE("Returning %i\n", *n
);
1892 if (param
->type
== D3DXPT_FLOAT
&&
1893 ((param
->class == D3DXPC_VECTOR
&& param
->columns
!= 2)
1894 || (param
->class == D3DXPC_MATRIX_ROWS
&& param
->rows
!= 2 && param
->columns
== 1)))
1896 TRACE("Vector fixup\n");
1898 /* all components (3,4) are clamped (0,255) and put in the INT */
1899 *n
= (INT
)(min(max(0.0f
, *((FLOAT
*)param
->data
+ 2)), 1.0f
) * INT_FLOAT_MULTI
);
1900 *n
+= ((INT
)(min(max(0.0f
, *((FLOAT
*)param
->data
+ 1)), 1.0f
) * INT_FLOAT_MULTI
)) << 8;
1901 *n
+= ((INT
)(min(max(0.0f
, *((FLOAT
*)param
->data
+ 0)), 1.0f
) * INT_FLOAT_MULTI
)) << 16;
1902 if (param
->columns
* param
->rows
> 3)
1904 *n
+= ((INT
)(min(max(0.0f
, *((FLOAT
*)param
->data
+ 3)), 1.0f
) * INT_FLOAT_MULTI
)) << 24;
1907 TRACE("Returning %i\n", *n
);
1912 WARN("Invalid argument specified\n");
1914 return D3DERR_INVALIDCALL
;
1917 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST INT
*n
, UINT count
)
1919 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1920 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1922 TRACE("iface %p, parameter %p, n %p, count %u\n", This
, parameter
, n
, count
);
1926 UINT i
, size
= min(count
, param
->bytes
/ sizeof(DWORD
));
1928 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
1930 switch (param
->class)
1934 case D3DXPC_MATRIX_ROWS
:
1935 for (i
= 0; i
< size
; ++i
)
1937 set_number((DWORD
*)param
->data
+ i
, param
->type
, &n
[i
], D3DXPT_INT
);
1946 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
1951 WARN("Invalid argument specified\n");
1953 return D3DERR_INVALIDCALL
;
1956 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, INT
*n
, UINT count
)
1958 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1959 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1961 TRACE("iface %p, parameter %p, n %p, count %u\n", This
, parameter
, n
, count
);
1963 if (n
&& param
&& (param
->class == D3DXPC_SCALAR
1964 || param
->class == D3DXPC_VECTOR
1965 || param
->class == D3DXPC_MATRIX_ROWS
1966 || param
->class == D3DXPC_MATRIX_COLUMNS
))
1968 UINT i
, size
= min(count
, param
->bytes
/ sizeof(DWORD
));
1970 for (i
= 0; i
< size
; ++i
)
1972 n
[i
] = get_int(param
->type
, (DWORD
*)param
->data
+ i
);
1977 WARN("Invalid argument specified\n");
1979 return D3DERR_INVALIDCALL
;
1982 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, FLOAT f
)
1984 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1985 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1987 TRACE("iface %p, parameter %p, f %f\n", This
, parameter
, f
);
1989 if (param
&& !param
->element_count
&& param
->rows
== 1 && param
->columns
== 1)
1991 set_number((DWORD
*)param
->data
, param
->type
, &f
, D3DXPT_FLOAT
);
1995 WARN("Invalid argument specified\n");
1997 return D3DERR_INVALIDCALL
;
2000 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, FLOAT
*f
)
2002 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2003 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2005 TRACE("iface %p, parameter %p, f %p\n", This
, parameter
, f
);
2007 if (f
&& param
&& !param
->element_count
&& param
->columns
== 1 && param
->rows
== 1)
2009 *f
= get_float(param
->type
, (DWORD
*)param
->data
);
2010 TRACE("Returning %f\n", *f
);
2014 WARN("Invalid argument specified\n");
2016 return D3DERR_INVALIDCALL
;
2019 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST FLOAT
*f
, UINT count
)
2021 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2022 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2024 TRACE("iface %p, parameter %p, f %p, count %u\n", This
, parameter
, f
, count
);
2028 UINT i
, size
= min(count
, param
->bytes
/ sizeof(DWORD
));
2030 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2032 switch (param
->class)
2036 case D3DXPC_MATRIX_ROWS
:
2037 for (i
= 0; i
< size
; ++i
)
2039 set_number((DWORD
*)param
->data
+ i
, param
->type
, &f
[i
], D3DXPT_FLOAT
);
2048 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2053 WARN("Invalid argument specified\n");
2055 return D3DERR_INVALIDCALL
;
2058 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, FLOAT
*f
, UINT count
)
2060 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2061 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2063 TRACE("iface %p, parameter %p, f %p, count %u\n", This
, parameter
, f
, count
);
2065 if (f
&& param
&& (param
->class == D3DXPC_SCALAR
2066 || param
->class == D3DXPC_VECTOR
2067 || param
->class == D3DXPC_MATRIX_ROWS
2068 || param
->class == D3DXPC_MATRIX_COLUMNS
))
2070 UINT i
, size
= min(count
, param
->bytes
/ sizeof(DWORD
));
2072 for (i
= 0; i
< size
; ++i
)
2074 f
[i
] = get_float(param
->type
, (DWORD
*)param
->data
+ i
);
2079 WARN("Invalid argument specified\n");
2081 return D3DERR_INVALIDCALL
;
2084 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXVECTOR4
*vector
)
2086 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2087 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2089 TRACE("iface %p, parameter %p, vector %p\n", This
, parameter
, vector
);
2091 if (param
&& !param
->element_count
)
2093 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2095 switch (param
->class)
2099 if (param
->type
== D3DXPT_INT
&& param
->bytes
== 4)
2103 TRACE("INT fixup\n");
2104 tmp
= (DWORD
)(max(min(vector
->z
, 1.0f
), 0.0f
) * INT_FLOAT_MULTI
);
2105 tmp
+= ((DWORD
)(max(min(vector
->y
, 1.0f
), 0.0f
) * INT_FLOAT_MULTI
)) << 8;
2106 tmp
+= ((DWORD
)(max(min(vector
->x
, 1.0f
), 0.0f
) * INT_FLOAT_MULTI
)) << 16;
2107 tmp
+= ((DWORD
)(max(min(vector
->w
, 1.0f
), 0.0f
) * INT_FLOAT_MULTI
)) << 24;
2109 *(INT
*)param
->data
= tmp
;
2112 set_vector(param
, vector
);
2115 case D3DXPC_MATRIX_ROWS
:
2121 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2126 WARN("Invalid argument specified\n");
2128 return D3DERR_INVALIDCALL
;
2131 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, D3DXVECTOR4
*vector
)
2133 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2134 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2136 TRACE("iface %p, parameter %p, vector %p\n", This
, parameter
, vector
);
2138 if (vector
&& param
&& !param
->element_count
)
2140 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2142 switch (param
->class)
2146 if (param
->type
== D3DXPT_INT
&& param
->bytes
== 4)
2148 TRACE("INT fixup\n");
2149 vector
->x
= (((*(INT
*)param
->data
) & 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE
;
2150 vector
->y
= (((*(INT
*)param
->data
) & 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE
;
2151 vector
->z
= ((*(INT
*)param
->data
) & 0xff) * INT_FLOAT_MULTI_INVERSE
;
2152 vector
->w
= (((*(INT
*)param
->data
) & 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE
;
2155 get_vector(param
, vector
);
2158 case D3DXPC_MATRIX_ROWS
:
2164 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2169 WARN("Invalid argument specified\n");
2171 return D3DERR_INVALIDCALL
;
2174 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXVECTOR4
*vector
, UINT count
)
2176 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2177 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2179 TRACE("iface %p, parameter %p, vector %p, count %u stub\n", This
, parameter
, vector
, count
);
2181 if (param
&& param
->element_count
&& param
->element_count
>= count
)
2185 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2187 switch (param
->class)
2190 for (i
= 0; i
< count
; ++i
)
2192 set_vector(get_parameter_struct(param
->member_handles
[i
]), &vector
[i
]);
2197 case D3DXPC_MATRIX_ROWS
:
2203 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2208 WARN("Invalid argument specified\n");
2210 return D3DERR_INVALIDCALL
;
2213 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, D3DXVECTOR4
*vector
, UINT count
)
2215 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2216 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2218 TRACE("iface %p, parameter %p, vector %p, count %u\n", This
, parameter
, vector
, count
);
2220 if (!count
) return D3D_OK
;
2222 if (vector
&& param
&& count
<= param
->element_count
)
2226 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2228 switch (param
->class)
2231 for (i
= 0; i
< count
; ++i
)
2233 get_vector(get_parameter_struct(param
->member_handles
[i
]), &vector
[i
]);
2238 case D3DXPC_MATRIX_ROWS
:
2244 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2249 WARN("Invalid argument specified\n");
2251 return D3DERR_INVALIDCALL
;
2254 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
)
2256 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2257 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2259 TRACE("iface %p, parameter %p, matrix %p\n", This
, parameter
, matrix
);
2261 if (param
&& !param
->element_count
)
2263 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2265 switch (param
->class)
2267 case D3DXPC_MATRIX_ROWS
:
2268 set_matrix(param
, matrix
);
2278 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2283 WARN("Invalid argument specified\n");
2285 return D3DERR_INVALIDCALL
;
2288 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
2290 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2291 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2293 TRACE("iface %p, parameter %p, matrix %p\n", This
, parameter
, matrix
);
2295 if (matrix
&& param
&& !param
->element_count
)
2297 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2299 switch (param
->class)
2301 case D3DXPC_MATRIX_ROWS
:
2302 get_matrix(param
, matrix
);
2312 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2317 WARN("Invalid argument specified\n");
2319 return D3DERR_INVALIDCALL
;
2322 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
, UINT count
)
2324 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2325 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2327 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This
, parameter
, matrix
, count
);
2329 if (param
&& param
->element_count
>= count
)
2333 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2335 switch (param
->class)
2337 case D3DXPC_MATRIX_ROWS
:
2338 for (i
= 0; i
< count
; ++i
)
2340 set_matrix(get_parameter_struct(param
->member_handles
[i
]), &matrix
[i
]);
2351 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2356 WARN("Invalid argument specified\n");
2358 return D3DERR_INVALIDCALL
;
2361 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
2363 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2364 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2366 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This
, parameter
, matrix
, count
);
2368 if (!count
) return D3D_OK
;
2370 if (matrix
&& param
&& count
<= param
->element_count
)
2374 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2376 switch (param
->class)
2378 case D3DXPC_MATRIX_ROWS
:
2379 for (i
= 0; i
< count
; ++i
)
2381 get_matrix(get_parameter_struct(param
->member_handles
[i
]), &matrix
[i
]);
2392 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2397 WARN("Invalid argument specified\n");
2399 return D3DERR_INVALIDCALL
;
2402 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
**matrix
, UINT count
)
2404 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2405 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2407 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This
, parameter
, matrix
, count
);
2409 if (param
&& count
<= param
->element_count
)
2413 switch (param
->class)
2415 case D3DXPC_MATRIX_ROWS
:
2416 for (i
= 0; i
< count
; ++i
)
2418 set_matrix(get_parameter_struct(param
->member_handles
[i
]), matrix
[i
]);
2428 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2433 WARN("Invalid argument specified\n");
2435 return D3DERR_INVALIDCALL
;
2438 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
2440 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2441 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2443 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This
, parameter
, matrix
, count
);
2445 if (!count
) return D3D_OK
;
2447 if (param
&& matrix
&& count
<= param
->element_count
)
2451 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2453 switch (param
->class)
2455 case D3DXPC_MATRIX_ROWS
:
2456 for (i
= 0; i
< count
; ++i
)
2458 get_matrix(get_parameter_struct(param
->member_handles
[i
]), matrix
[i
]);
2468 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2473 WARN("Invalid argument specified\n");
2475 return D3DERR_INVALIDCALL
;
2478 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
)
2480 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2481 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2484 TRACE("iface %p, parameter %p, matrix %p\n", This
, parameter
, matrix
);
2486 if (param
&& !param
->element_count
)
2488 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2490 switch (param
->class)
2492 case D3DXPC_MATRIX_ROWS
:
2493 set_matrix(param
, D3DXMatrixTranspose(&m
, matrix
));
2503 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2508 WARN("Invalid argument specified\n");
2510 return D3DERR_INVALIDCALL
;
2513 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
2515 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2516 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2519 TRACE("iface %p, parameter %p, matrix %p\n", This
, parameter
, matrix
);
2521 if (matrix
&& param
&& !param
->element_count
)
2523 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2525 switch (param
->class)
2529 get_matrix(param
, matrix
);
2532 case D3DXPC_MATRIX_ROWS
:
2533 get_matrix(param
, &m
);
2534 D3DXMatrixTranspose(matrix
, &m
);
2542 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2547 WARN("Invalid argument specified\n");
2549 return D3DERR_INVALIDCALL
;
2552 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
, UINT count
)
2554 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2555 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2558 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This
, parameter
, matrix
, count
);
2560 if (param
&& param
->element_count
>= count
)
2564 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2566 switch (param
->class)
2568 case D3DXPC_MATRIX_ROWS
:
2569 for (i
= 0; i
< count
; ++i
)
2571 set_matrix(get_parameter_struct(param
->member_handles
[i
]), D3DXMatrixTranspose(&m
, &matrix
[i
]));
2582 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2587 WARN("Invalid argument specified\n");
2589 return D3DERR_INVALIDCALL
;
2592 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
2594 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2595 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2597 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This
, parameter
, matrix
, count
);
2599 if (!count
) return D3D_OK
;
2601 if (matrix
&& param
&& count
<= param
->element_count
)
2605 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2607 switch (param
->class)
2609 case D3DXPC_MATRIX_ROWS
:
2610 for (i
= 0; i
< count
; ++i
)
2614 get_matrix(get_parameter_struct(param
->member_handles
[i
]), &m
);
2615 D3DXMatrixTranspose(&matrix
[i
], &m
);
2626 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2631 WARN("Invalid argument specified\n");
2633 return D3DERR_INVALIDCALL
;
2636 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
**matrix
, UINT count
)
2638 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2639 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2642 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This
, parameter
, matrix
, count
);
2644 if (param
&& count
<= param
->element_count
)
2648 switch (param
->class)
2650 case D3DXPC_MATRIX_ROWS
:
2651 for (i
= 0; i
< count
; ++i
)
2653 set_matrix(get_parameter_struct(param
->member_handles
[i
]), D3DXMatrixTranspose(&m
, matrix
[i
]));
2663 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2668 WARN("Invalid argument specified\n");
2670 return D3DERR_INVALIDCALL
;
2673 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
2675 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2676 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2678 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This
, parameter
, matrix
, count
);
2680 if (!count
) return D3D_OK
;
2682 if (matrix
&& param
&& count
<= param
->element_count
)
2687 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2689 switch (param
->class)
2691 case D3DXPC_MATRIX_ROWS
:
2692 for (i
= 0; i
< count
; ++i
)
2694 get_matrix(get_parameter_struct(param
->member_handles
[i
]), &m
);
2695 D3DXMatrixTranspose(matrix
[i
], &m
);
2705 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2710 WARN("Invalid argument specified\n");
2712 return D3DERR_INVALIDCALL
;
2715 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPCSTR string
)
2717 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2719 FIXME("iface %p, parameter %p, string %p stub\n", This
, parameter
, string
);
2724 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPCSTR
*string
)
2726 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2727 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2729 TRACE("iface %p, parameter %p, string %p\n", This
, parameter
, string
);
2731 if (string
&& param
&& !param
->element_count
&& param
->type
== D3DXPT_STRING
)
2733 *string
= *(LPCSTR
*)param
->data
;
2734 TRACE("Returning %s\n", debugstr_a(*string
));
2738 WARN("Invalid argument specified\n");
2740 return D3DERR_INVALIDCALL
;
2743 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPDIRECT3DBASETEXTURE9 texture
)
2745 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2746 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2748 TRACE("iface %p, parameter %p, texture %p\n", This
, parameter
, texture
);
2750 if (param
&& !param
->element_count
&&
2751 (param
->type
== D3DXPT_TEXTURE
|| param
->type
== D3DXPT_TEXTURE1D
2752 || param
->type
== D3DXPT_TEXTURE2D
|| param
->type
== D3DXPT_TEXTURE3D
2753 || param
->type
== D3DXPT_TEXTURECUBE
))
2755 LPDIRECT3DBASETEXTURE9 oltexture
= *(LPDIRECT3DBASETEXTURE9
*)param
->data
;
2757 if (texture
) IDirect3DBaseTexture9_AddRef(texture
);
2758 if (oltexture
) IDirect3DBaseTexture9_Release(oltexture
);
2760 *(LPDIRECT3DBASETEXTURE9
*)param
->data
= texture
;
2765 WARN("Invalid argument specified\n");
2767 return D3DERR_INVALIDCALL
;
2770 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPDIRECT3DBASETEXTURE9
*texture
)
2772 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2773 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2775 TRACE("iface %p, parameter %p, texture %p\n", This
, parameter
, texture
);
2777 if (texture
&& param
&& !param
->element_count
&&
2778 (param
->type
== D3DXPT_TEXTURE
|| param
->type
== D3DXPT_TEXTURE1D
2779 || param
->type
== D3DXPT_TEXTURE2D
|| param
->type
== D3DXPT_TEXTURE3D
2780 || param
->type
== D3DXPT_TEXTURECUBE
))
2782 *texture
= *(LPDIRECT3DBASETEXTURE9
*)param
->data
;
2783 if (*texture
) IDirect3DBaseTexture9_AddRef(*texture
);
2784 TRACE("Returning %p\n", *texture
);
2788 WARN("Invalid argument specified\n");
2790 return D3DERR_INVALIDCALL
;
2793 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPDIRECT3DPIXELSHADER9
*pshader
)
2795 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2796 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2798 TRACE("iface %p, parameter %p, pshader %p\n", This
, parameter
, pshader
);
2800 if (pshader
&& param
&& !param
->element_count
&& param
->type
== D3DXPT_PIXELSHADER
)
2802 *pshader
= *(LPDIRECT3DPIXELSHADER9
*)param
->data
;
2803 if (*pshader
) IDirect3DPixelShader9_AddRef(*pshader
);
2804 TRACE("Returning %p\n", *pshader
);
2808 WARN("Invalid argument specified\n");
2810 return D3DERR_INVALIDCALL
;
2813 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPDIRECT3DVERTEXSHADER9
*vshader
)
2815 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2816 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2818 TRACE("iface %p, parameter %p, vshader %p\n", This
, parameter
, vshader
);
2820 if (vshader
&& param
&& !param
->element_count
&& param
->type
== D3DXPT_VERTEXSHADER
)
2822 *vshader
= *(LPDIRECT3DVERTEXSHADER9
*)param
->data
;
2823 if (*vshader
) IDirect3DVertexShader9_AddRef(*vshader
);
2824 TRACE("Returning %p\n", *vshader
);
2828 WARN("Invalid argument specified\n");
2830 return D3DERR_INVALIDCALL
;
2833 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, UINT start
, UINT end
)
2835 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2837 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This
, parameter
, start
, end
);
2842 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl
=
2844 /*** IUnknown methods ***/
2845 ID3DXBaseEffectImpl_QueryInterface
,
2846 ID3DXBaseEffectImpl_AddRef
,
2847 ID3DXBaseEffectImpl_Release
,
2848 /*** ID3DXBaseEffect methods ***/
2849 ID3DXBaseEffectImpl_GetDesc
,
2850 ID3DXBaseEffectImpl_GetParameterDesc
,
2851 ID3DXBaseEffectImpl_GetTechniqueDesc
,
2852 ID3DXBaseEffectImpl_GetPassDesc
,
2853 ID3DXBaseEffectImpl_GetFunctionDesc
,
2854 ID3DXBaseEffectImpl_GetParameter
,
2855 ID3DXBaseEffectImpl_GetParameterByName
,
2856 ID3DXBaseEffectImpl_GetParameterBySemantic
,
2857 ID3DXBaseEffectImpl_GetParameterElement
,
2858 ID3DXBaseEffectImpl_GetTechnique
,
2859 ID3DXBaseEffectImpl_GetTechniqueByName
,
2860 ID3DXBaseEffectImpl_GetPass
,
2861 ID3DXBaseEffectImpl_GetPassByName
,
2862 ID3DXBaseEffectImpl_GetFunction
,
2863 ID3DXBaseEffectImpl_GetFunctionByName
,
2864 ID3DXBaseEffectImpl_GetAnnotation
,
2865 ID3DXBaseEffectImpl_GetAnnotationByName
,
2866 ID3DXBaseEffectImpl_SetValue
,
2867 ID3DXBaseEffectImpl_GetValue
,
2868 ID3DXBaseEffectImpl_SetBool
,
2869 ID3DXBaseEffectImpl_GetBool
,
2870 ID3DXBaseEffectImpl_SetBoolArray
,
2871 ID3DXBaseEffectImpl_GetBoolArray
,
2872 ID3DXBaseEffectImpl_SetInt
,
2873 ID3DXBaseEffectImpl_GetInt
,
2874 ID3DXBaseEffectImpl_SetIntArray
,
2875 ID3DXBaseEffectImpl_GetIntArray
,
2876 ID3DXBaseEffectImpl_SetFloat
,
2877 ID3DXBaseEffectImpl_GetFloat
,
2878 ID3DXBaseEffectImpl_SetFloatArray
,
2879 ID3DXBaseEffectImpl_GetFloatArray
,
2880 ID3DXBaseEffectImpl_SetVector
,
2881 ID3DXBaseEffectImpl_GetVector
,
2882 ID3DXBaseEffectImpl_SetVectorArray
,
2883 ID3DXBaseEffectImpl_GetVectorArray
,
2884 ID3DXBaseEffectImpl_SetMatrix
,
2885 ID3DXBaseEffectImpl_GetMatrix
,
2886 ID3DXBaseEffectImpl_SetMatrixArray
,
2887 ID3DXBaseEffectImpl_GetMatrixArray
,
2888 ID3DXBaseEffectImpl_SetMatrixPointerArray
,
2889 ID3DXBaseEffectImpl_GetMatrixPointerArray
,
2890 ID3DXBaseEffectImpl_SetMatrixTranspose
,
2891 ID3DXBaseEffectImpl_GetMatrixTranspose
,
2892 ID3DXBaseEffectImpl_SetMatrixTransposeArray
,
2893 ID3DXBaseEffectImpl_GetMatrixTransposeArray
,
2894 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray
,
2895 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray
,
2896 ID3DXBaseEffectImpl_SetString
,
2897 ID3DXBaseEffectImpl_GetString
,
2898 ID3DXBaseEffectImpl_SetTexture
,
2899 ID3DXBaseEffectImpl_GetTexture
,
2900 ID3DXBaseEffectImpl_GetPixelShader
,
2901 ID3DXBaseEffectImpl_GetVertexShader
,
2902 ID3DXBaseEffectImpl_SetArrayRange
,
2905 static inline struct ID3DXEffectImpl
*impl_from_ID3DXEffect(ID3DXEffect
*iface
)
2907 return CONTAINING_RECORD(iface
, struct ID3DXEffectImpl
, ID3DXEffect_iface
);
2910 /*** IUnknown methods ***/
2911 static HRESULT WINAPI
ID3DXEffectImpl_QueryInterface(ID3DXEffect
*iface
, REFIID riid
, void **object
)
2913 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), object
);
2915 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
2916 IsEqualGUID(riid
, &IID_ID3DXEffect
))
2918 iface
->lpVtbl
->AddRef(iface
);
2923 ERR("Interface %s not found\n", debugstr_guid(riid
));
2925 return E_NOINTERFACE
;
2928 static ULONG WINAPI
ID3DXEffectImpl_AddRef(ID3DXEffect
*iface
)
2930 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2932 TRACE("(%p)->(): AddRef from %u\n", This
, This
->ref
);
2934 return InterlockedIncrement(&This
->ref
);
2937 static ULONG WINAPI
ID3DXEffectImpl_Release(ID3DXEffect
*iface
)
2939 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2940 ULONG ref
= InterlockedDecrement(&This
->ref
);
2942 TRACE("(%p)->(): Release from %u\n", This
, ref
+ 1);
2947 HeapFree(GetProcessHeap(), 0, This
);
2953 /*** ID3DXBaseEffect methods ***/
2954 static HRESULT WINAPI
ID3DXEffectImpl_GetDesc(ID3DXEffect
*iface
, D3DXEFFECT_DESC
*desc
)
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_GetDesc(base
, desc
);
2964 static HRESULT WINAPI
ID3DXEffectImpl_GetParameterDesc(ID3DXEffect
*iface
, D3DXHANDLE parameter
, D3DXPARAMETER_DESC
*desc
)
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_GetParameterDesc(base
, parameter
, desc
);
2974 static HRESULT WINAPI
ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect
*iface
, D3DXHANDLE technique
, D3DXTECHNIQUE_DESC
*desc
)
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_GetTechniqueDesc(base
, technique
, desc
);
2984 static HRESULT WINAPI
ID3DXEffectImpl_GetPassDesc(ID3DXEffect
*iface
, D3DXHANDLE pass
, D3DXPASS_DESC
*desc
)
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_GetPassDesc(base
, pass
, desc
);
2994 static HRESULT WINAPI
ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect
*iface
, D3DXHANDLE shader
, D3DXFUNCTION_DESC
*desc
)
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_GetFunctionDesc(base
, shader
, desc
);
3004 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameter(ID3DXEffect
*iface
, D3DXHANDLE parameter
, UINT index
)
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_GetParameter(base
, parameter
, index
);
3014 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameterByName(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPCSTR name
)
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_GetParameterByName(base
, parameter
, name
);
3024 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPCSTR semantic
)
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_GetParameterBySemantic(base
, parameter
, semantic
);
3034 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameterElement(ID3DXEffect
*iface
, D3DXHANDLE parameter
, UINT index
)
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_GetParameterElement(base
, parameter
, index
);
3044 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetTechnique(ID3DXEffect
*iface
, UINT index
)
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_GetTechnique(base
, index
);
3054 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect
*iface
, LPCSTR name
)
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_GetTechniqueByName(base
, name
);
3064 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetPass(ID3DXEffect
*iface
, D3DXHANDLE technique
, UINT index
)
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_GetPass(base
, technique
, index
);
3074 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetPassByName(ID3DXEffect
*iface
, D3DXHANDLE technique
, LPCSTR name
)
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_GetPassByName(base
, technique
, name
);
3084 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetFunction(ID3DXEffect
*iface
, UINT index
)
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_GetFunction(base
, index
);
3094 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetFunctionByName(ID3DXEffect
*iface
, LPCSTR name
)
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_GetFunctionByName(base
, name
);
3104 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetAnnotation(ID3DXEffect
*iface
, D3DXHANDLE object
, UINT index
)
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_GetAnnotation(base
, object
, index
);
3114 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect
*iface
, D3DXHANDLE object
, LPCSTR name
)
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_GetAnnotationByName(base
, object
, name
);
3124 static HRESULT WINAPI
ID3DXEffectImpl_SetValue(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPCVOID data
, UINT bytes
)
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_SetValue(base
, parameter
, data
, bytes
);
3134 static HRESULT WINAPI
ID3DXEffectImpl_GetValue(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPVOID data
, UINT bytes
)
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_GetValue(base
, parameter
, data
, bytes
);
3144 static HRESULT WINAPI
ID3DXEffectImpl_SetBool(ID3DXEffect
*iface
, D3DXHANDLE parameter
, BOOL b
)
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_SetBool(base
, parameter
, b
);
3154 static HRESULT WINAPI
ID3DXEffectImpl_GetBool(ID3DXEffect
*iface
, D3DXHANDLE parameter
, BOOL
*b
)
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_GetBool(base
, parameter
, b
);
3164 static HRESULT WINAPI
ID3DXEffectImpl_SetBoolArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST BOOL
*b
, 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_SetBoolArray(base
, parameter
, b
, count
);
3174 static HRESULT WINAPI
ID3DXEffectImpl_GetBoolArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, BOOL
*b
, UINT count
)
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_GetBoolArray(base
, parameter
, b
, count
);
3184 static HRESULT WINAPI
ID3DXEffectImpl_SetInt(ID3DXEffect
*iface
, D3DXHANDLE parameter
, INT n
)
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_SetInt(base
, parameter
, n
);
3194 static HRESULT WINAPI
ID3DXEffectImpl_GetInt(ID3DXEffect
*iface
, D3DXHANDLE parameter
, INT
*n
)
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_GetInt(base
, parameter
, n
);
3204 static HRESULT WINAPI
ID3DXEffectImpl_SetIntArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST INT
*n
, 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_SetIntArray(base
, parameter
, n
, count
);
3214 static HRESULT WINAPI
ID3DXEffectImpl_GetIntArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, INT
*n
, UINT count
)
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_GetIntArray(base
, parameter
, n
, count
);
3224 static HRESULT WINAPI
ID3DXEffectImpl_SetFloat(ID3DXEffect
*iface
, D3DXHANDLE parameter
, FLOAT f
)
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_SetFloat(base
, parameter
, f
);
3234 static HRESULT WINAPI
ID3DXEffectImpl_GetFloat(ID3DXEffect
*iface
, D3DXHANDLE parameter
, FLOAT
*f
)
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_GetFloat(base
, parameter
, f
);
3244 static HRESULT WINAPI
ID3DXEffectImpl_SetFloatArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST FLOAT
*f
, 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_SetFloatArray(base
, parameter
, f
, count
);
3254 static HRESULT WINAPI
ID3DXEffectImpl_GetFloatArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, FLOAT
*f
, 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_GetFloatArray(base
, parameter
, f
, count
);
3264 static HRESULT WINAPI
ID3DXEffectImpl_SetVector(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXVECTOR4
*vector
)
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_SetVector(base
, parameter
, vector
);
3274 static HRESULT WINAPI
ID3DXEffectImpl_GetVector(ID3DXEffect
*iface
, D3DXHANDLE parameter
, D3DXVECTOR4
*vector
)
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_GetVector(base
, parameter
, vector
);
3284 static HRESULT WINAPI
ID3DXEffectImpl_SetVectorArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXVECTOR4
*vector
, UINT count
)
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_SetVectorArray(base
, parameter
, vector
, count
);
3294 static HRESULT WINAPI
ID3DXEffectImpl_GetVectorArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, D3DXVECTOR4
*vector
, 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_GetVectorArray(base
, parameter
, vector
, count
);
3304 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrix(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
)
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_SetMatrix(base
, parameter
, matrix
);
3314 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrix(ID3DXEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
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_GetMatrix(base
, parameter
, matrix
);
3324 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST 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_SetMatrixArray(base
, parameter
, matrix
, count
);
3334 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
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_GetMatrixArray(base
, parameter
, matrix
, count
);
3344 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
**matrix
, UINT count
)
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_SetMatrixPointerArray(base
, parameter
, matrix
, count
);
3354 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
3356 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3357 ID3DXBaseEffect
*base
= This
->base_effect
;
3359 TRACE("Forward iface %p, base %p\n", This
, base
);
3361 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base
, parameter
, matrix
, count
);
3364 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
)
3366 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3367 ID3DXBaseEffect
*base
= This
->base_effect
;
3369 TRACE("Forward iface %p, base %p\n", This
, base
);
3371 return ID3DXBaseEffectImpl_SetMatrixTranspose(base
, parameter
, matrix
);
3374 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
3376 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3377 ID3DXBaseEffect
*base
= This
->base_effect
;
3379 TRACE("Forward iface %p, base %p\n", This
, base
);
3381 return ID3DXBaseEffectImpl_GetMatrixTranspose(base
, parameter
, matrix
);
3384 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
, UINT count
)
3386 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3387 ID3DXBaseEffect
*base
= This
->base_effect
;
3389 TRACE("Forward iface %p, base %p\n", This
, base
);
3391 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base
, parameter
, matrix
, count
);
3394 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
3396 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3397 ID3DXBaseEffect
*base
= This
->base_effect
;
3399 TRACE("Forward iface %p, base %p\n", This
, base
);
3401 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base
, parameter
, matrix
, count
);
3404 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
**matrix
, UINT count
)
3406 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3407 ID3DXBaseEffect
*base
= This
->base_effect
;
3409 TRACE("Forward iface %p, base %p\n", This
, base
);
3411 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base
, parameter
, matrix
, count
);
3414 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
3416 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3417 ID3DXBaseEffect
*base
= This
->base_effect
;
3419 TRACE("Forward iface %p, base %p\n", This
, base
);
3421 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base
, parameter
, matrix
, count
);
3424 static HRESULT WINAPI
ID3DXEffectImpl_SetString(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPCSTR string
)
3426 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3427 ID3DXBaseEffect
*base
= This
->base_effect
;
3429 TRACE("Forward iface %p, base %p\n", This
, base
);
3431 return ID3DXBaseEffectImpl_SetString(base
, parameter
, string
);
3434 static HRESULT WINAPI
ID3DXEffectImpl_GetString(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPCSTR
*string
)
3436 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3437 ID3DXBaseEffect
*base
= This
->base_effect
;
3439 TRACE("Forward iface %p, base %p\n", This
, base
);
3441 return ID3DXBaseEffectImpl_GetString(base
, parameter
, string
);
3444 static HRESULT WINAPI
ID3DXEffectImpl_SetTexture(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPDIRECT3DBASETEXTURE9 texture
)
3446 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3447 ID3DXBaseEffect
*base
= This
->base_effect
;
3449 TRACE("Forward iface %p, base %p\n", This
, base
);
3451 return ID3DXBaseEffectImpl_SetTexture(base
, parameter
, texture
);
3454 static HRESULT WINAPI
ID3DXEffectImpl_GetTexture(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPDIRECT3DBASETEXTURE9
*texture
)
3456 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3457 ID3DXBaseEffect
*base
= This
->base_effect
;
3459 TRACE("Forward iface %p, base %p\n", This
, base
);
3461 return ID3DXBaseEffectImpl_GetTexture(base
, parameter
, texture
);
3464 static HRESULT WINAPI
ID3DXEffectImpl_GetPixelShader(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPDIRECT3DPIXELSHADER9
*pshader
)
3466 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3467 ID3DXBaseEffect
*base
= This
->base_effect
;
3469 TRACE("Forward iface %p, base %p\n", This
, base
);
3471 return ID3DXBaseEffectImpl_GetPixelShader(base
, parameter
, pshader
);
3474 static HRESULT WINAPI
ID3DXEffectImpl_GetVertexShader(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPDIRECT3DVERTEXSHADER9
*vshader
)
3476 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3477 ID3DXBaseEffect
*base
= This
->base_effect
;
3479 TRACE("Forward iface %p, base %p\n", This
, base
);
3481 return ID3DXBaseEffectImpl_GetVertexShader(base
, parameter
, vshader
);
3484 static HRESULT WINAPI
ID3DXEffectImpl_SetArrayRange(ID3DXEffect
*iface
, D3DXHANDLE parameter
, UINT start
, UINT end
)
3486 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3487 ID3DXBaseEffect
*base
= This
->base_effect
;
3489 TRACE("Forward iface %p, base %p\n", This
, base
);
3491 return ID3DXBaseEffectImpl_SetArrayRange(base
, parameter
, start
, end
);
3494 /*** ID3DXEffect methods ***/
3495 static HRESULT WINAPI
ID3DXEffectImpl_GetPool(ID3DXEffect
*iface
, LPD3DXEFFECTPOOL
*pool
)
3497 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3499 TRACE("iface %p, pool %p\n", This
, pool
);
3503 WARN("Invalid argument supplied.\n");
3504 return D3DERR_INVALIDCALL
;
3509 This
->pool
->lpVtbl
->AddRef(This
->pool
);
3514 TRACE("Returning pool %p\n", *pool
);
3519 static HRESULT WINAPI
ID3DXEffectImpl_SetTechnique(ID3DXEffect
*iface
, D3DXHANDLE technique
)
3521 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3522 struct ID3DXBaseEffectImpl
*base
= impl_from_ID3DXBaseEffect(This
->base_effect
);
3523 struct d3dx_technique
*tech
= is_valid_technique(base
, technique
);
3525 TRACE("iface %p, technique %p\n", This
, technique
);
3529 This
->active_technique
= get_technique_handle(tech
);
3530 TRACE("Technique %p\n", tech
);
3534 WARN("Invalid argument supplied.\n");
3536 return D3DERR_INVALIDCALL
;
3539 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect
*iface
)
3541 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3543 TRACE("iface %p\n", This
);
3545 return This
->active_technique
;
3548 static HRESULT WINAPI
ID3DXEffectImpl_ValidateTechnique(ID3DXEffect
* iface
, D3DXHANDLE technique
)
3550 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3552 FIXME("(%p)->(%p): stub\n", This
, technique
);
3557 static HRESULT WINAPI
ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect
* iface
, D3DXHANDLE technique
, D3DXHANDLE
* next_technique
)
3559 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3561 FIXME("(%p)->(%p, %p): stub\n", This
, technique
, next_technique
);
3566 static BOOL WINAPI
ID3DXEffectImpl_IsParameterUsed(ID3DXEffect
* iface
, D3DXHANDLE parameter
, D3DXHANDLE technique
)
3568 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3570 FIXME("(%p)->(%p, %p): stub\n", This
, parameter
, technique
);
3575 static HRESULT WINAPI
ID3DXEffectImpl_Begin(ID3DXEffect
*iface
, UINT
*passes
, DWORD flags
)
3577 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3578 struct d3dx_technique
*technique
= get_technique_struct(This
->active_technique
);
3580 FIXME("iface %p, passes %p, flags %#x partial stub\n", This
, passes
, flags
);
3582 if (passes
&& technique
)
3584 if (This
->manager
|| flags
& D3DXFX_DONOTSAVESTATE
)
3586 TRACE("State capturing disabled.\n");
3590 FIXME("State capturing not supported, yet!\n");
3593 *passes
= technique
->pass_count
;
3598 WARN("Invalid argument supplied.\n");
3600 return D3DERR_INVALIDCALL
;
3603 static HRESULT WINAPI
ID3DXEffectImpl_BeginPass(ID3DXEffect
*iface
, UINT pass
)
3605 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3606 struct d3dx_technique
*technique
= get_technique_struct(This
->active_technique
);
3608 TRACE("iface %p, pass %u\n", This
, pass
);
3610 if (technique
&& pass
< technique
->pass_count
&& !This
->active_pass
)
3612 This
->active_pass
= technique
->pass_handles
[pass
];
3614 FIXME("No states applied, yet!\n");
3619 WARN("Invalid argument supplied.\n");
3621 return D3DERR_INVALIDCALL
;
3624 static HRESULT WINAPI
ID3DXEffectImpl_CommitChanges(ID3DXEffect
* iface
)
3626 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3628 FIXME("(%p)->(): stub\n", This
);
3633 static HRESULT WINAPI
ID3DXEffectImpl_EndPass(ID3DXEffect
*iface
)
3635 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3637 TRACE("iface %p\n", This
);
3639 if (This
->active_pass
)
3641 This
->active_pass
= NULL
;
3645 WARN("Invalid call.\n");
3647 return D3DERR_INVALIDCALL
;
3650 static HRESULT WINAPI
ID3DXEffectImpl_End(ID3DXEffect
* iface
)
3652 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3654 FIXME("(%p)->(): stub\n", This
);
3659 static HRESULT WINAPI
ID3DXEffectImpl_GetDevice(ID3DXEffect
*iface
, LPDIRECT3DDEVICE9
*device
)
3661 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3663 TRACE("iface %p, device %p\n", This
, device
);
3667 WARN("Invalid argument supplied.\n");
3668 return D3DERR_INVALIDCALL
;
3671 IDirect3DDevice9_AddRef(This
->device
);
3673 *device
= This
->device
;
3675 TRACE("Returning device %p\n", *device
);
3680 static HRESULT WINAPI
ID3DXEffectImpl_OnLostDevice(ID3DXEffect
* iface
)
3682 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3684 FIXME("(%p)->(): stub\n", This
);
3689 static HRESULT WINAPI
ID3DXEffectImpl_OnResetDevice(ID3DXEffect
* iface
)
3691 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3693 FIXME("(%p)->(): stub\n", This
);
3698 static HRESULT WINAPI
ID3DXEffectImpl_SetStateManager(ID3DXEffect
*iface
, LPD3DXEFFECTSTATEMANAGER manager
)
3700 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3702 TRACE("iface %p, manager %p\n", This
, manager
);
3704 if (manager
) IUnknown_AddRef(manager
);
3705 if (This
->manager
) IUnknown_Release(This
->manager
);
3707 This
->manager
= manager
;
3712 static HRESULT WINAPI
ID3DXEffectImpl_GetStateManager(ID3DXEffect
*iface
, LPD3DXEFFECTSTATEMANAGER
*manager
)
3714 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3716 TRACE("iface %p, manager %p\n", This
, manager
);
3720 WARN("Invalid argument supplied.\n");
3721 return D3DERR_INVALIDCALL
;
3724 if (This
->manager
) IUnknown_AddRef(This
->manager
);
3725 *manager
= This
->manager
;
3730 static HRESULT WINAPI
ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect
* iface
)
3732 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3734 FIXME("(%p)->(): stub\n", This
);
3739 static D3DXHANDLE WINAPI
ID3DXEffectImpl_EndParameterBlock(ID3DXEffect
* iface
)
3741 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3743 FIXME("(%p)->(): stub\n", This
);
3748 static HRESULT WINAPI
ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect
* iface
, D3DXHANDLE parameter_block
)
3750 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3752 FIXME("(%p)->(%p): stub\n", This
, parameter_block
);
3757 static HRESULT WINAPI
ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect
* iface
, D3DXHANDLE parameter_block
)
3759 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3761 FIXME("(%p)->(%p): stub\n", This
, parameter_block
);
3766 static HRESULT WINAPI
ID3DXEffectImpl_CloneEffect(ID3DXEffect
* iface
, LPDIRECT3DDEVICE9 device
, LPD3DXEFFECT
* effect
)
3768 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3770 FIXME("(%p)->(%p, %p): stub\n", This
, device
, effect
);
3775 static HRESULT WINAPI
ID3DXEffectImpl_SetRawValue(ID3DXEffect
* iface
, D3DXHANDLE parameter
, LPCVOID data
, UINT byte_offset
, UINT bytes
)
3777 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3779 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This
, parameter
, data
, byte_offset
, bytes
);
3784 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl
=
3786 /*** IUnknown methods ***/
3787 ID3DXEffectImpl_QueryInterface
,
3788 ID3DXEffectImpl_AddRef
,
3789 ID3DXEffectImpl_Release
,
3790 /*** ID3DXBaseEffect methods ***/
3791 ID3DXEffectImpl_GetDesc
,
3792 ID3DXEffectImpl_GetParameterDesc
,
3793 ID3DXEffectImpl_GetTechniqueDesc
,
3794 ID3DXEffectImpl_GetPassDesc
,
3795 ID3DXEffectImpl_GetFunctionDesc
,
3796 ID3DXEffectImpl_GetParameter
,
3797 ID3DXEffectImpl_GetParameterByName
,
3798 ID3DXEffectImpl_GetParameterBySemantic
,
3799 ID3DXEffectImpl_GetParameterElement
,
3800 ID3DXEffectImpl_GetTechnique
,
3801 ID3DXEffectImpl_GetTechniqueByName
,
3802 ID3DXEffectImpl_GetPass
,
3803 ID3DXEffectImpl_GetPassByName
,
3804 ID3DXEffectImpl_GetFunction
,
3805 ID3DXEffectImpl_GetFunctionByName
,
3806 ID3DXEffectImpl_GetAnnotation
,
3807 ID3DXEffectImpl_GetAnnotationByName
,
3808 ID3DXEffectImpl_SetValue
,
3809 ID3DXEffectImpl_GetValue
,
3810 ID3DXEffectImpl_SetBool
,
3811 ID3DXEffectImpl_GetBool
,
3812 ID3DXEffectImpl_SetBoolArray
,
3813 ID3DXEffectImpl_GetBoolArray
,
3814 ID3DXEffectImpl_SetInt
,
3815 ID3DXEffectImpl_GetInt
,
3816 ID3DXEffectImpl_SetIntArray
,
3817 ID3DXEffectImpl_GetIntArray
,
3818 ID3DXEffectImpl_SetFloat
,
3819 ID3DXEffectImpl_GetFloat
,
3820 ID3DXEffectImpl_SetFloatArray
,
3821 ID3DXEffectImpl_GetFloatArray
,
3822 ID3DXEffectImpl_SetVector
,
3823 ID3DXEffectImpl_GetVector
,
3824 ID3DXEffectImpl_SetVectorArray
,
3825 ID3DXEffectImpl_GetVectorArray
,
3826 ID3DXEffectImpl_SetMatrix
,
3827 ID3DXEffectImpl_GetMatrix
,
3828 ID3DXEffectImpl_SetMatrixArray
,
3829 ID3DXEffectImpl_GetMatrixArray
,
3830 ID3DXEffectImpl_SetMatrixPointerArray
,
3831 ID3DXEffectImpl_GetMatrixPointerArray
,
3832 ID3DXEffectImpl_SetMatrixTranspose
,
3833 ID3DXEffectImpl_GetMatrixTranspose
,
3834 ID3DXEffectImpl_SetMatrixTransposeArray
,
3835 ID3DXEffectImpl_GetMatrixTransposeArray
,
3836 ID3DXEffectImpl_SetMatrixTransposePointerArray
,
3837 ID3DXEffectImpl_GetMatrixTransposePointerArray
,
3838 ID3DXEffectImpl_SetString
,
3839 ID3DXEffectImpl_GetString
,
3840 ID3DXEffectImpl_SetTexture
,
3841 ID3DXEffectImpl_GetTexture
,
3842 ID3DXEffectImpl_GetPixelShader
,
3843 ID3DXEffectImpl_GetVertexShader
,
3844 ID3DXEffectImpl_SetArrayRange
,
3845 /*** ID3DXEffect methods ***/
3846 ID3DXEffectImpl_GetPool
,
3847 ID3DXEffectImpl_SetTechnique
,
3848 ID3DXEffectImpl_GetCurrentTechnique
,
3849 ID3DXEffectImpl_ValidateTechnique
,
3850 ID3DXEffectImpl_FindNextValidTechnique
,
3851 ID3DXEffectImpl_IsParameterUsed
,
3852 ID3DXEffectImpl_Begin
,
3853 ID3DXEffectImpl_BeginPass
,
3854 ID3DXEffectImpl_CommitChanges
,
3855 ID3DXEffectImpl_EndPass
,
3856 ID3DXEffectImpl_End
,
3857 ID3DXEffectImpl_GetDevice
,
3858 ID3DXEffectImpl_OnLostDevice
,
3859 ID3DXEffectImpl_OnResetDevice
,
3860 ID3DXEffectImpl_SetStateManager
,
3861 ID3DXEffectImpl_GetStateManager
,
3862 ID3DXEffectImpl_BeginParameterBlock
,
3863 ID3DXEffectImpl_EndParameterBlock
,
3864 ID3DXEffectImpl_ApplyParameterBlock
,
3865 ID3DXEffectImpl_DeleteParameterBlock
,
3866 ID3DXEffectImpl_CloneEffect
,
3867 ID3DXEffectImpl_SetRawValue
3870 static inline struct ID3DXEffectCompilerImpl
*impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler
*iface
)
3872 return CONTAINING_RECORD(iface
, struct ID3DXEffectCompilerImpl
, ID3DXEffectCompiler_iface
);
3875 /*** IUnknown methods ***/
3876 static HRESULT WINAPI
ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler
*iface
, REFIID riid
, void **object
)
3878 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), object
);
3880 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
3881 IsEqualGUID(riid
, &IID_ID3DXEffectCompiler
))
3883 iface
->lpVtbl
->AddRef(iface
);
3888 ERR("Interface %s not found\n", debugstr_guid(riid
));
3890 return E_NOINTERFACE
;
3893 static ULONG WINAPI
ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler
*iface
)
3895 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3897 TRACE("iface %p: AddRef from %u\n", iface
, This
->ref
);
3899 return InterlockedIncrement(&This
->ref
);
3902 static ULONG WINAPI
ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler
*iface
)
3904 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3905 ULONG ref
= InterlockedDecrement(&This
->ref
);
3907 TRACE("iface %p: Release from %u\n", iface
, ref
+ 1);
3911 free_effect_compiler(This
);
3912 HeapFree(GetProcessHeap(), 0, This
);
3918 /*** ID3DXBaseEffect methods ***/
3919 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler
*iface
, D3DXEFFECT_DESC
*desc
)
3921 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3922 ID3DXBaseEffect
*base
= This
->base_effect
;
3924 TRACE("Forward iface %p, base %p\n", This
, base
);
3926 return ID3DXBaseEffectImpl_GetDesc(base
, desc
);
3929 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, D3DXPARAMETER_DESC
*desc
)
3931 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3932 ID3DXBaseEffect
*base
= This
->base_effect
;
3934 TRACE("Forward iface %p, base %p\n", This
, base
);
3936 return ID3DXBaseEffectImpl_GetParameterDesc(base
, parameter
, desc
);
3939 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler
*iface
, D3DXHANDLE technique
, D3DXTECHNIQUE_DESC
*desc
)
3941 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3942 ID3DXBaseEffect
*base
= This
->base_effect
;
3944 TRACE("Forward iface %p, base %p\n", This
, base
);
3946 return ID3DXBaseEffectImpl_GetTechniqueDesc(base
, technique
, desc
);
3949 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler
*iface
, D3DXHANDLE pass
, D3DXPASS_DESC
*desc
)
3951 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3952 ID3DXBaseEffect
*base
= This
->base_effect
;
3954 TRACE("Forward iface %p, base %p\n", This
, base
);
3956 return ID3DXBaseEffectImpl_GetPassDesc(base
, pass
, desc
);
3959 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler
*iface
, D3DXHANDLE shader
, D3DXFUNCTION_DESC
*desc
)
3961 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3962 ID3DXBaseEffect
*base
= This
->base_effect
;
3964 TRACE("Forward iface %p, base %p\n", This
, base
);
3966 return ID3DXBaseEffectImpl_GetFunctionDesc(base
, shader
, desc
);
3969 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, UINT index
)
3971 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3972 ID3DXBaseEffect
*base
= This
->base_effect
;
3974 TRACE("Forward iface %p, base %p\n", This
, base
);
3976 return ID3DXBaseEffectImpl_GetParameter(base
, parameter
, index
);
3979 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPCSTR name
)
3981 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3982 ID3DXBaseEffect
*base
= This
->base_effect
;
3984 TRACE("Forward iface %p, base %p\n", This
, base
);
3986 return ID3DXBaseEffectImpl_GetParameterByName(base
, parameter
, name
);
3989 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPCSTR semantic
)
3991 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3992 ID3DXBaseEffect
*base
= This
->base_effect
;
3994 TRACE("Forward iface %p, base %p\n", This
, base
);
3996 return ID3DXBaseEffectImpl_GetParameterBySemantic(base
, parameter
, semantic
);
3999 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, UINT index
)
4001 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4002 ID3DXBaseEffect
*base
= This
->base_effect
;
4004 TRACE("Forward iface %p, base %p\n", This
, base
);
4006 return ID3DXBaseEffectImpl_GetParameterElement(base
, parameter
, index
);
4009 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler
*iface
, UINT index
)
4011 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4012 ID3DXBaseEffect
*base
= This
->base_effect
;
4014 TRACE("Forward iface %p, base %p\n", This
, base
);
4016 return ID3DXBaseEffectImpl_GetTechnique(base
, index
);
4019 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler
*iface
, LPCSTR name
)
4021 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4022 ID3DXBaseEffect
*base
= This
->base_effect
;
4024 TRACE("Forward iface %p, base %p\n", This
, base
);
4026 return ID3DXBaseEffectImpl_GetTechniqueByName(base
, name
);
4029 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler
*iface
, D3DXHANDLE technique
, UINT index
)
4031 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4032 ID3DXBaseEffect
*base
= This
->base_effect
;
4034 TRACE("Forward iface %p, base %p\n", This
, base
);
4036 return ID3DXBaseEffectImpl_GetPass(base
, technique
, index
);
4039 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler
*iface
, D3DXHANDLE technique
, LPCSTR name
)
4041 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4042 ID3DXBaseEffect
*base
= This
->base_effect
;
4044 TRACE("Forward iface %p, base %p\n", This
, base
);
4046 return ID3DXBaseEffectImpl_GetPassByName(base
, technique
, name
);
4049 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler
*iface
, UINT index
)
4051 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4052 ID3DXBaseEffect
*base
= This
->base_effect
;
4054 TRACE("Forward iface %p, base %p\n", This
, base
);
4056 return ID3DXBaseEffectImpl_GetFunction(base
, index
);
4059 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler
*iface
, LPCSTR name
)
4061 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4062 ID3DXBaseEffect
*base
= This
->base_effect
;
4064 TRACE("Forward iface %p, base %p\n", This
, base
);
4066 return ID3DXBaseEffectImpl_GetFunctionByName(base
, name
);
4069 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler
*iface
, D3DXHANDLE object
, UINT index
)
4071 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4072 ID3DXBaseEffect
*base
= This
->base_effect
;
4074 TRACE("Forward iface %p, base %p\n", This
, base
);
4076 return ID3DXBaseEffectImpl_GetAnnotation(base
, object
, index
);
4079 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler
*iface
, D3DXHANDLE object
, LPCSTR name
)
4081 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4082 ID3DXBaseEffect
*base
= This
->base_effect
;
4084 TRACE("Forward iface %p, base %p\n", This
, base
);
4086 return ID3DXBaseEffectImpl_GetAnnotationByName(base
, object
, name
);
4089 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPCVOID data
, UINT bytes
)
4091 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4092 ID3DXBaseEffect
*base
= This
->base_effect
;
4094 TRACE("Forward iface %p, base %p\n", This
, base
);
4096 return ID3DXBaseEffectImpl_SetValue(base
, parameter
, data
, bytes
);
4099 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPVOID data
, UINT bytes
)
4101 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4102 ID3DXBaseEffect
*base
= This
->base_effect
;
4104 TRACE("Forward iface %p, base %p\n", This
, base
);
4106 return ID3DXBaseEffectImpl_GetValue(base
, parameter
, data
, bytes
);
4109 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL b
)
4111 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4112 ID3DXBaseEffect
*base
= This
->base_effect
;
4114 TRACE("Forward iface %p, base %p\n", This
, base
);
4116 return ID3DXBaseEffectImpl_SetBool(base
, parameter
, b
);
4119 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL
*b
)
4121 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4122 ID3DXBaseEffect
*base
= This
->base_effect
;
4124 TRACE("Forward iface %p, base %p\n", This
, base
);
4126 return ID3DXBaseEffectImpl_GetBool(base
, parameter
, b
);
4129 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST BOOL
*b
, UINT count
)
4131 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4132 ID3DXBaseEffect
*base
= This
->base_effect
;
4134 TRACE("Forward iface %p, base %p\n", This
, base
);
4136 return ID3DXBaseEffectImpl_SetBoolArray(base
, parameter
, b
, count
);
4139 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL
*b
, UINT count
)
4141 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4142 ID3DXBaseEffect
*base
= This
->base_effect
;
4144 TRACE("Forward iface %p, base %p\n", This
, base
);
4146 return ID3DXBaseEffectImpl_GetBoolArray(base
, parameter
, b
, count
);
4149 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, INT n
)
4151 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4152 ID3DXBaseEffect
*base
= This
->base_effect
;
4154 TRACE("Forward iface %p, base %p\n", This
, base
);
4156 return ID3DXBaseEffectImpl_SetInt(base
, parameter
, n
);
4159 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, INT
*n
)
4161 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4162 ID3DXBaseEffect
*base
= This
->base_effect
;
4164 TRACE("Forward iface %p, base %p\n", This
, base
);
4166 return ID3DXBaseEffectImpl_GetInt(base
, parameter
, n
);
4169 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST INT
*n
, UINT count
)
4171 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4172 ID3DXBaseEffect
*base
= This
->base_effect
;
4174 TRACE("Forward iface %p, base %p\n", This
, base
);
4176 return ID3DXBaseEffectImpl_SetIntArray(base
, parameter
, n
, count
);
4179 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, INT
*n
, UINT count
)
4181 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4182 ID3DXBaseEffect
*base
= This
->base_effect
;
4184 TRACE("Forward iface %p, base %p\n", This
, base
);
4186 return ID3DXBaseEffectImpl_GetIntArray(base
, parameter
, n
, count
);
4189 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, FLOAT f
)
4191 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4192 ID3DXBaseEffect
*base
= This
->base_effect
;
4194 TRACE("Forward iface %p, base %p\n", This
, base
);
4196 return ID3DXBaseEffectImpl_SetFloat(base
, parameter
, f
);
4199 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, FLOAT
*f
)
4201 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4202 ID3DXBaseEffect
*base
= This
->base_effect
;
4204 TRACE("Forward iface %p, base %p\n", This
, base
);
4206 return ID3DXBaseEffectImpl_GetFloat(base
, parameter
, f
);
4209 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST FLOAT
*f
, UINT count
)
4211 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4212 ID3DXBaseEffect
*base
= This
->base_effect
;
4214 TRACE("Forward iface %p, base %p\n", This
, base
);
4216 return ID3DXBaseEffectImpl_SetFloatArray(base
, parameter
, f
, count
);
4219 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, FLOAT
*f
, UINT count
)
4221 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4222 ID3DXBaseEffect
*base
= This
->base_effect
;
4224 TRACE("Forward iface %p, base %p\n", This
, base
);
4226 return ID3DXBaseEffectImpl_GetFloatArray(base
, parameter
, f
, count
);
4229 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST D3DXVECTOR4
*vector
)
4231 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4232 ID3DXBaseEffect
*base
= This
->base_effect
;
4234 TRACE("Forward iface %p, base %p\n", This
, base
);
4236 return ID3DXBaseEffectImpl_SetVector(base
, parameter
, vector
);
4239 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, D3DXVECTOR4
*vector
)
4241 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4242 ID3DXBaseEffect
*base
= This
->base_effect
;
4244 TRACE("Forward iface %p, base %p\n", This
, base
);
4246 return ID3DXBaseEffectImpl_GetVector(base
, parameter
, vector
);
4249 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST D3DXVECTOR4
*vector
, UINT count
)
4251 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4252 ID3DXBaseEffect
*base
= This
->base_effect
;
4254 TRACE("Forward iface %p, base %p\n", This
, base
);
4256 return ID3DXBaseEffectImpl_SetVectorArray(base
, parameter
, vector
, count
);
4259 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, D3DXVECTOR4
*vector
, UINT count
)
4261 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4262 ID3DXBaseEffect
*base
= This
->base_effect
;
4264 TRACE("Forward iface %p, base %p\n", This
, base
);
4266 return ID3DXBaseEffectImpl_GetVectorArray(base
, parameter
, vector
, count
);
4269 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
)
4271 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4272 ID3DXBaseEffect
*base
= This
->base_effect
;
4274 TRACE("Forward iface %p, base %p\n", This
, base
);
4276 return ID3DXBaseEffectImpl_SetMatrix(base
, parameter
, matrix
);
4279 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
4281 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4282 ID3DXBaseEffect
*base
= This
->base_effect
;
4284 TRACE("Forward iface %p, base %p\n", This
, base
);
4286 return ID3DXBaseEffectImpl_GetMatrix(base
, parameter
, matrix
);
4289 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
, UINT count
)
4291 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4292 ID3DXBaseEffect
*base
= This
->base_effect
;
4294 TRACE("Forward iface %p, base %p\n", This
, base
);
4296 return ID3DXBaseEffectImpl_SetMatrixArray(base
, parameter
, matrix
, count
);
4299 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
4301 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4302 ID3DXBaseEffect
*base
= This
->base_effect
;
4304 TRACE("Forward iface %p, base %p\n", This
, base
);
4306 return ID3DXBaseEffectImpl_GetMatrixArray(base
, parameter
, matrix
, count
);
4309 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
**matrix
, UINT count
)
4311 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4312 ID3DXBaseEffect
*base
= This
->base_effect
;
4314 TRACE("Forward iface %p, base %p\n", This
, base
);
4316 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base
, parameter
, matrix
, count
);
4319 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
4321 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4322 ID3DXBaseEffect
*base
= This
->base_effect
;
4324 TRACE("Forward iface %p, base %p\n", This
, base
);
4326 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base
, parameter
, matrix
, count
);
4329 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
)
4331 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4332 ID3DXBaseEffect
*base
= This
->base_effect
;
4334 TRACE("Forward iface %p, base %p\n", This
, base
);
4336 return ID3DXBaseEffectImpl_SetMatrixTranspose(base
, parameter
, matrix
);
4339 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
4341 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4342 ID3DXBaseEffect
*base
= This
->base_effect
;
4344 TRACE("Forward iface %p, base %p\n", This
, base
);
4346 return ID3DXBaseEffectImpl_GetMatrixTranspose(base
, parameter
, matrix
);
4349 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
, UINT count
)
4351 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4352 ID3DXBaseEffect
*base
= This
->base_effect
;
4354 TRACE("Forward iface %p, base %p\n", This
, base
);
4356 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base
, parameter
, matrix
, count
);
4359 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
4361 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4362 ID3DXBaseEffect
*base
= This
->base_effect
;
4364 TRACE("Forward iface %p, base %p\n", This
, base
);
4366 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base
, parameter
, matrix
, count
);
4369 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
**matrix
, UINT count
)
4371 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4372 ID3DXBaseEffect
*base
= This
->base_effect
;
4374 TRACE("Forward iface %p, base %p\n", This
, base
);
4376 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base
, parameter
, matrix
, count
);
4379 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
4381 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4382 ID3DXBaseEffect
*base
= This
->base_effect
;
4384 TRACE("Forward iface %p, base %p\n", This
, base
);
4386 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base
, parameter
, matrix
, count
);
4389 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPCSTR string
)
4391 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4392 ID3DXBaseEffect
*base
= This
->base_effect
;
4394 TRACE("Forward iface %p, base %p\n", This
, base
);
4396 return ID3DXBaseEffectImpl_SetString(base
, parameter
, string
);
4399 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPCSTR
*string
)
4401 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4402 ID3DXBaseEffect
*base
= This
->base_effect
;
4404 TRACE("Forward iface %p, base %p\n", This
, base
);
4406 return ID3DXBaseEffectImpl_GetString(base
, parameter
, string
);
4409 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPDIRECT3DBASETEXTURE9 texture
)
4411 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4412 ID3DXBaseEffect
*base
= This
->base_effect
;
4414 TRACE("Forward iface %p, base %p\n", This
, base
);
4416 return ID3DXBaseEffectImpl_SetTexture(base
, parameter
, texture
);
4419 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPDIRECT3DBASETEXTURE9
*texture
)
4421 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4422 ID3DXBaseEffect
*base
= This
->base_effect
;
4424 TRACE("Forward iface %p, base %p\n", This
, base
);
4426 return ID3DXBaseEffectImpl_GetTexture(base
, parameter
, texture
);
4429 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPDIRECT3DPIXELSHADER9
*pshader
)
4431 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4432 ID3DXBaseEffect
*base
= This
->base_effect
;
4434 TRACE("Forward iface %p, base %p\n", This
, base
);
4436 return ID3DXBaseEffectImpl_GetPixelShader(base
, parameter
, pshader
);
4439 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPDIRECT3DVERTEXSHADER9
*vshader
)
4441 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4442 ID3DXBaseEffect
*base
= This
->base_effect
;
4444 TRACE("Forward iface %p, base %p\n", This
, base
);
4446 return ID3DXBaseEffectImpl_GetVertexShader(base
, parameter
, vshader
);
4449 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, UINT start
, UINT end
)
4451 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4452 ID3DXBaseEffect
*base
= This
->base_effect
;
4454 TRACE("Forward iface %p, base %p\n", This
, base
);
4456 return ID3DXBaseEffectImpl_SetArrayRange(base
, parameter
, start
, end
);
4459 /*** ID3DXEffectCompiler methods ***/
4460 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL literal
)
4462 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4464 FIXME("iface %p, parameter %p, literal %u\n", This
, parameter
, literal
);
4469 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL
*literal
)
4471 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4473 FIXME("iface %p, parameter %p, literal %p\n", This
, parameter
, literal
);
4478 static HRESULT WINAPI
ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler
*iface
, DWORD flags
,
4479 LPD3DXBUFFER
*effect
, LPD3DXBUFFER
*error_msgs
)
4481 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4483 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This
, flags
, effect
, error_msgs
);
4488 static HRESULT WINAPI
ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler
*iface
, D3DXHANDLE function
,
4489 LPCSTR target
, DWORD flags
, LPD3DXBUFFER
*shader
, LPD3DXBUFFER
*error_msgs
, LPD3DXCONSTANTTABLE
*constant_table
)
4491 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4493 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
4494 This
, function
, target
, flags
, shader
, error_msgs
, constant_table
);
4499 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl
=
4501 /*** IUnknown methods ***/
4502 ID3DXEffectCompilerImpl_QueryInterface
,
4503 ID3DXEffectCompilerImpl_AddRef
,
4504 ID3DXEffectCompilerImpl_Release
,
4505 /*** ID3DXBaseEffect methods ***/
4506 ID3DXEffectCompilerImpl_GetDesc
,
4507 ID3DXEffectCompilerImpl_GetParameterDesc
,
4508 ID3DXEffectCompilerImpl_GetTechniqueDesc
,
4509 ID3DXEffectCompilerImpl_GetPassDesc
,
4510 ID3DXEffectCompilerImpl_GetFunctionDesc
,
4511 ID3DXEffectCompilerImpl_GetParameter
,
4512 ID3DXEffectCompilerImpl_GetParameterByName
,
4513 ID3DXEffectCompilerImpl_GetParameterBySemantic
,
4514 ID3DXEffectCompilerImpl_GetParameterElement
,
4515 ID3DXEffectCompilerImpl_GetTechnique
,
4516 ID3DXEffectCompilerImpl_GetTechniqueByName
,
4517 ID3DXEffectCompilerImpl_GetPass
,
4518 ID3DXEffectCompilerImpl_GetPassByName
,
4519 ID3DXEffectCompilerImpl_GetFunction
,
4520 ID3DXEffectCompilerImpl_GetFunctionByName
,
4521 ID3DXEffectCompilerImpl_GetAnnotation
,
4522 ID3DXEffectCompilerImpl_GetAnnotationByName
,
4523 ID3DXEffectCompilerImpl_SetValue
,
4524 ID3DXEffectCompilerImpl_GetValue
,
4525 ID3DXEffectCompilerImpl_SetBool
,
4526 ID3DXEffectCompilerImpl_GetBool
,
4527 ID3DXEffectCompilerImpl_SetBoolArray
,
4528 ID3DXEffectCompilerImpl_GetBoolArray
,
4529 ID3DXEffectCompilerImpl_SetInt
,
4530 ID3DXEffectCompilerImpl_GetInt
,
4531 ID3DXEffectCompilerImpl_SetIntArray
,
4532 ID3DXEffectCompilerImpl_GetIntArray
,
4533 ID3DXEffectCompilerImpl_SetFloat
,
4534 ID3DXEffectCompilerImpl_GetFloat
,
4535 ID3DXEffectCompilerImpl_SetFloatArray
,
4536 ID3DXEffectCompilerImpl_GetFloatArray
,
4537 ID3DXEffectCompilerImpl_SetVector
,
4538 ID3DXEffectCompilerImpl_GetVector
,
4539 ID3DXEffectCompilerImpl_SetVectorArray
,
4540 ID3DXEffectCompilerImpl_GetVectorArray
,
4541 ID3DXEffectCompilerImpl_SetMatrix
,
4542 ID3DXEffectCompilerImpl_GetMatrix
,
4543 ID3DXEffectCompilerImpl_SetMatrixArray
,
4544 ID3DXEffectCompilerImpl_GetMatrixArray
,
4545 ID3DXEffectCompilerImpl_SetMatrixPointerArray
,
4546 ID3DXEffectCompilerImpl_GetMatrixPointerArray
,
4547 ID3DXEffectCompilerImpl_SetMatrixTranspose
,
4548 ID3DXEffectCompilerImpl_GetMatrixTranspose
,
4549 ID3DXEffectCompilerImpl_SetMatrixTransposeArray
,
4550 ID3DXEffectCompilerImpl_GetMatrixTransposeArray
,
4551 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray
,
4552 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray
,
4553 ID3DXEffectCompilerImpl_SetString
,
4554 ID3DXEffectCompilerImpl_GetString
,
4555 ID3DXEffectCompilerImpl_SetTexture
,
4556 ID3DXEffectCompilerImpl_GetTexture
,
4557 ID3DXEffectCompilerImpl_GetPixelShader
,
4558 ID3DXEffectCompilerImpl_GetVertexShader
,
4559 ID3DXEffectCompilerImpl_SetArrayRange
,
4560 /*** ID3DXEffectCompiler methods ***/
4561 ID3DXEffectCompilerImpl_SetLiteral
,
4562 ID3DXEffectCompilerImpl_GetLiteral
,
4563 ID3DXEffectCompilerImpl_CompileEffect
,
4564 ID3DXEffectCompilerImpl_CompileShader
,
4567 static HRESULT
d3dx9_parse_sampler(struct d3dx_sampler
*sampler
, const char *data
, const char **ptr
, D3DXHANDLE
*objects
)
4571 struct d3dx_state
*states
;
4573 read_dword(ptr
, &sampler
->state_count
);
4574 TRACE("Count: %u\n", sampler
->state_count
);
4576 states
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*states
) * sampler
->state_count
);
4579 ERR("Out of memory\n");
4580 return E_OUTOFMEMORY
;
4583 for (i
= 0; i
< sampler
->state_count
; ++i
)
4585 hr
= d3dx9_parse_state(&states
[i
], data
, ptr
, objects
);
4588 WARN("Failed to parse state\n");
4593 sampler
->states
= states
;
4599 for (i
= 0; i
< sampler
->state_count
; ++i
)
4601 free_state(&states
[i
]);
4604 HeapFree(GetProcessHeap(), 0, states
);
4609 static HRESULT
d3dx9_parse_value(struct d3dx_parameter
*param
, void *value
, const char *data
, const char **ptr
, D3DXHANDLE
*objects
)
4616 if (param
->element_count
)
4618 param
->data
= value
;
4620 for (i
= 0; i
< param
->element_count
; ++i
)
4622 struct d3dx_parameter
*member
= get_parameter_struct(param
->member_handles
[i
]);
4624 hr
= d3dx9_parse_value(member
, value
? (char *)value
+ old_size
: NULL
, data
, ptr
, objects
);
4627 WARN("Failed to parse value\n");
4631 old_size
+= member
->bytes
;
4637 switch(param
->class)
4641 case D3DXPC_MATRIX_ROWS
:
4642 case D3DXPC_MATRIX_COLUMNS
:
4643 param
->data
= value
;
4647 param
->data
= value
;
4649 for (i
= 0; i
< param
->member_count
; ++i
)
4651 struct d3dx_parameter
*member
= get_parameter_struct(param
->member_handles
[i
]);
4653 hr
= d3dx9_parse_value(member
, (char *)value
+ old_size
, data
, ptr
, objects
);
4656 WARN("Failed to parse value\n");
4660 old_size
+= member
->bytes
;
4665 switch (param
->type
)
4668 case D3DXPT_TEXTURE
:
4669 case D3DXPT_TEXTURE1D
:
4670 case D3DXPT_TEXTURE2D
:
4671 case D3DXPT_TEXTURE3D
:
4672 case D3DXPT_TEXTURECUBE
:
4673 case D3DXPT_PIXELSHADER
:
4674 case D3DXPT_VERTEXSHADER
:
4675 read_dword(ptr
, &id
);
4676 TRACE("Id: %u\n", id
);
4677 objects
[id
] = get_parameter_handle(param
);
4678 param
->data
= value
;
4681 case D3DXPT_SAMPLER
:
4682 case D3DXPT_SAMPLER1D
:
4683 case D3DXPT_SAMPLER2D
:
4684 case D3DXPT_SAMPLER3D
:
4685 case D3DXPT_SAMPLERCUBE
:
4687 struct d3dx_sampler
*sampler
;
4689 sampler
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*sampler
));
4692 ERR("Out of memory\n");
4693 return E_OUTOFMEMORY
;
4696 hr
= d3dx9_parse_sampler(sampler
, data
, ptr
, objects
);
4699 HeapFree(GetProcessHeap(), 0, sampler
);
4700 WARN("Failed to parse sampler\n");
4704 param
->data
= sampler
;
4709 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
4715 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
4722 static HRESULT
d3dx9_parse_init_value(struct d3dx_parameter
*param
, const char *data
, const char *ptr
, D3DXHANDLE
*objects
)
4724 UINT size
= param
->bytes
;
4728 TRACE("param size: %u\n", size
);
4732 value
= HeapAlloc(GetProcessHeap(), 0, size
);
4735 ERR("Failed to allocate data memory.\n");
4736 return E_OUTOFMEMORY
;
4739 TRACE("Data: %s.\n", debugstr_an(ptr
, size
));
4740 memcpy(value
, ptr
, size
);
4743 hr
= d3dx9_parse_value(param
, value
, data
, &ptr
, objects
);
4746 WARN("Failed to parse value\n");
4747 HeapFree(GetProcessHeap(), 0, value
);
4754 static HRESULT
d3dx9_parse_name(char **name
, const char *ptr
)
4758 read_dword(&ptr
, &size
);
4759 TRACE("Name size: %#x\n", size
);
4766 *name
= HeapAlloc(GetProcessHeap(), 0, size
);
4769 ERR("Failed to allocate name memory.\n");
4770 return E_OUTOFMEMORY
;
4773 TRACE("Name: %s.\n", debugstr_an(ptr
, size
));
4774 memcpy(*name
, ptr
, size
);
4779 static HRESULT
d3dx9_copy_data(char **str
, const char **ptr
)
4783 read_dword(ptr
, &size
);
4784 TRACE("Data size: %#x\n", size
);
4786 *str
= HeapAlloc(GetProcessHeap(), 0, size
);
4789 ERR("Failed to allocate name memory.\n");
4790 return E_OUTOFMEMORY
;
4793 TRACE("Data: %s.\n", debugstr_an(*ptr
, size
));
4794 memcpy(*str
, *ptr
, size
);
4796 *ptr
+= ((size
+ 3) & ~3);
4801 static HRESULT
d3dx9_parse_data(struct d3dx_parameter
*param
, const char **ptr
, LPDIRECT3DDEVICE9 device
)
4806 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param
->name
), debug_d3dxparameter_type(param
->type
));
4808 read_dword(ptr
, &size
);
4809 TRACE("Data size: %#x\n", size
);
4813 TRACE("Size is 0\n");
4814 *(void **)param
->data
= NULL
;
4818 switch (param
->type
)
4821 /* re-read with size (sizeof(DWORD) = 4) */
4822 hr
= d3dx9_parse_name((LPSTR
*)param
->data
, *ptr
- 4);
4825 WARN("Failed to parse string data\n");
4830 case D3DXPT_VERTEXSHADER
:
4831 hr
= IDirect3DDevice9_CreateVertexShader(device
, (DWORD
*)*ptr
, (LPDIRECT3DVERTEXSHADER9
*)param
->data
);
4834 WARN("Failed to create vertex shader\n");
4839 case D3DXPT_PIXELSHADER
:
4840 hr
= IDirect3DDevice9_CreatePixelShader(device
, (DWORD
*)*ptr
, (LPDIRECT3DPIXELSHADER9
*)param
->data
);
4843 WARN("Failed to create pixel shader\n");
4849 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
4854 *ptr
+= ((size
+ 3) & ~3);
4859 static HRESULT
d3dx9_parse_effect_typedef(struct d3dx_parameter
*param
, const char *data
, const char **ptr
,
4860 struct d3dx_parameter
*parent
, UINT flags
)
4864 D3DXHANDLE
*member_handles
= NULL
;
4867 param
->flags
= flags
;
4871 read_dword(ptr
, ¶m
->type
);
4872 TRACE("Type: %s\n", debug_d3dxparameter_type(param
->type
));
4874 read_dword(ptr
, ¶m
->class);
4875 TRACE("Class: %s\n", debug_d3dxparameter_class(param
->class));
4877 read_dword(ptr
, &offset
);
4878 TRACE("Type name offset: %#x\n", offset
);
4879 hr
= d3dx9_parse_name(¶m
->name
, data
+ offset
);
4882 WARN("Failed to parse name\n");
4886 read_dword(ptr
, &offset
);
4887 TRACE("Type semantic offset: %#x\n", offset
);
4888 hr
= d3dx9_parse_name(¶m
->semantic
, data
+ offset
);
4891 WARN("Failed to parse semantic\n");
4895 read_dword(ptr
, ¶m
->element_count
);
4896 TRACE("Elements: %u\n", param
->element_count
);
4898 switch (param
->class)
4901 read_dword(ptr
, ¶m
->columns
);
4902 TRACE("Columns: %u\n", param
->columns
);
4904 read_dword(ptr
, ¶m
->rows
);
4905 TRACE("Rows: %u\n", param
->rows
);
4907 /* sizeof(DWORD) * rows * columns */
4908 param
->bytes
= 4 * param
->rows
* param
->columns
;
4912 case D3DXPC_MATRIX_ROWS
:
4913 case D3DXPC_MATRIX_COLUMNS
:
4914 read_dword(ptr
, ¶m
->rows
);
4915 TRACE("Rows: %u\n", param
->rows
);
4917 read_dword(ptr
, ¶m
->columns
);
4918 TRACE("Columns: %u\n", param
->columns
);
4920 /* sizeof(DWORD) * rows * columns */
4921 param
->bytes
= 4 * param
->rows
* param
->columns
;
4925 read_dword(ptr
, ¶m
->member_count
);
4926 TRACE("Members: %u\n", param
->member_count
);
4930 switch (param
->type
)
4933 param
->bytes
= sizeof(LPCSTR
);
4936 case D3DXPT_PIXELSHADER
:
4937 param
->bytes
= sizeof(LPDIRECT3DPIXELSHADER9
);
4940 case D3DXPT_VERTEXSHADER
:
4941 param
->bytes
= sizeof(LPDIRECT3DVERTEXSHADER9
);
4944 case D3DXPT_TEXTURE
:
4945 case D3DXPT_TEXTURE1D
:
4946 case D3DXPT_TEXTURE2D
:
4947 case D3DXPT_TEXTURE3D
:
4948 case D3DXPT_TEXTURECUBE
:
4949 param
->bytes
= sizeof(LPDIRECT3DBASETEXTURE9
);
4952 case D3DXPT_SAMPLER
:
4953 case D3DXPT_SAMPLER1D
:
4954 case D3DXPT_SAMPLER2D
:
4955 case D3DXPT_SAMPLER3D
:
4956 case D3DXPT_SAMPLERCUBE
:
4961 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
4967 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
4974 param
->type
= parent
->type
;
4975 param
->class = parent
->class;
4976 param
->name
= parent
->name
;
4977 param
->semantic
= parent
->semantic
;
4978 param
->element_count
= 0;
4979 param
->annotation_count
= 0;
4980 param
->member_count
= parent
->member_count
;
4981 param
->bytes
= parent
->bytes
;
4982 param
->rows
= parent
->rows
;
4983 param
->columns
= parent
->columns
;
4986 if (param
->element_count
)
4988 unsigned int param_bytes
= 0;
4989 const char *save_ptr
= *ptr
;
4991 member_handles
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*member_handles
) * param
->element_count
);
4992 if (!member_handles
)
4994 ERR("Out of memory\n");
4999 for (i
= 0; i
< param
->element_count
; ++i
)
5001 struct d3dx_parameter
*member
;
5004 member
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*member
));
5007 ERR("Out of memory\n");
5012 member_handles
[i
] = get_parameter_handle(member
);
5014 hr
= d3dx9_parse_effect_typedef(member
, data
, ptr
, param
, flags
);
5017 WARN("Failed to parse member\n");
5021 param_bytes
+= member
->bytes
;
5024 param
->bytes
= param_bytes
;
5026 else if (param
->member_count
)
5028 member_handles
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*member_handles
) * param
->member_count
);
5029 if (!member_handles
)
5031 ERR("Out of memory\n");
5036 for (i
= 0; i
< param
->member_count
; ++i
)
5038 struct d3dx_parameter
*member
;
5040 member
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*member
));
5043 ERR("Out of memory\n");
5048 member_handles
[i
] = get_parameter_handle(member
);
5050 hr
= d3dx9_parse_effect_typedef(member
, data
, ptr
, NULL
, flags
);
5053 WARN("Failed to parse member\n");
5057 param
->bytes
+= member
->bytes
;
5061 param
->member_handles
= member_handles
;
5071 if (param
->element_count
) count
= param
->element_count
;
5072 else count
= param
->member_count
;
5074 for (i
= 0; i
< count
; ++i
)
5076 free_parameter(member_handles
[i
], param
->element_count
!= 0, TRUE
);
5078 HeapFree(GetProcessHeap(), 0, member_handles
);
5083 HeapFree(GetProcessHeap(), 0, param
->name
);
5084 HeapFree(GetProcessHeap(), 0, param
->semantic
);
5087 param
->semantic
= NULL
;
5092 static HRESULT
d3dx9_parse_effect_annotation(struct d3dx_parameter
*anno
, const char *data
, const char **ptr
, D3DXHANDLE
*objects
)
5098 anno
->flags
= D3DX_PARAMETER_ANNOTATION
;
5100 read_dword(ptr
, &offset
);
5101 TRACE("Typedef offset: %#x\n", offset
);
5102 ptr2
= data
+ offset
;
5103 hr
= d3dx9_parse_effect_typedef(anno
, data
, &ptr2
, NULL
, D3DX_PARAMETER_ANNOTATION
);
5106 WARN("Failed to parse type definition\n");
5110 read_dword(ptr
, &offset
);
5111 TRACE("Value offset: %#x\n", offset
);
5112 hr
= d3dx9_parse_init_value(anno
, data
, data
+ offset
, objects
);
5115 WARN("Failed to parse value\n");
5122 static HRESULT
d3dx9_parse_state(struct d3dx_state
*state
, const char *data
, const char **ptr
, D3DXHANDLE
*objects
)
5127 struct d3dx_parameter
*parameter
;
5129 parameter
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*parameter
));
5132 ERR("Out of memory\n");
5133 return E_OUTOFMEMORY
;
5136 state
->type
= ST_CONSTANT
;
5138 read_dword(ptr
, &state
->operation
);
5139 TRACE("Operation: %#x (%s)\n", state
->operation
, state_table
[state
->operation
].name
);
5141 read_dword(ptr
, &state
->index
);
5142 TRACE("Index: %#x\n", state
->index
);
5144 read_dword(ptr
, &offset
);
5145 TRACE("Typedef offset: %#x\n", offset
);
5146 ptr2
= data
+ offset
;
5147 hr
= d3dx9_parse_effect_typedef(parameter
, data
, &ptr2
, NULL
, 0);
5150 WARN("Failed to parse type definition\n");
5154 read_dword(ptr
, &offset
);
5155 TRACE("Value offset: %#x\n", offset
);
5156 hr
= d3dx9_parse_init_value(parameter
, data
, data
+ offset
, objects
);
5159 WARN("Failed to parse value\n");
5163 state
->parameter
= get_parameter_handle(parameter
);
5169 free_parameter(get_parameter_handle(parameter
), FALSE
, FALSE
);
5174 static HRESULT
d3dx9_parse_effect_parameter(struct d3dx_parameter
*param
, const char *data
, const char **ptr
, D3DXHANDLE
*objects
)
5179 D3DXHANDLE
*annotation_handles
= NULL
;
5182 read_dword(ptr
, &offset
);
5183 TRACE("Typedef offset: %#x\n", offset
);
5184 ptr2
= data
+ offset
;
5186 read_dword(ptr
, &offset
);
5187 TRACE("Value offset: %#x\n", offset
);
5189 read_dword(ptr
, ¶m
->flags
);
5190 TRACE("Flags: %#x\n", param
->flags
);
5192 read_dword(ptr
, ¶m
->annotation_count
);
5193 TRACE("Annotation count: %u\n", param
->annotation_count
);
5195 hr
= d3dx9_parse_effect_typedef(param
, data
, &ptr2
, NULL
, param
->flags
);
5198 WARN("Failed to parse type definition\n");
5202 hr
= d3dx9_parse_init_value(param
, data
, data
+ offset
, objects
);
5205 WARN("Failed to parse value\n");
5209 if (param
->annotation_count
)
5211 annotation_handles
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*annotation_handles
) * param
->annotation_count
);
5212 if (!annotation_handles
)
5214 ERR("Out of memory\n");
5219 for (i
= 0; i
< param
->annotation_count
; ++i
)
5221 struct d3dx_parameter
*annotation
;
5223 annotation
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*annotation
));
5226 ERR("Out of memory\n");
5231 annotation_handles
[i
] = get_parameter_handle(annotation
);
5233 hr
= d3dx9_parse_effect_annotation(annotation
, data
, ptr
, objects
);
5236 WARN("Failed to parse annotation\n");
5242 param
->annotation_handles
= annotation_handles
;
5248 if (annotation_handles
)
5250 for (i
= 0; i
< param
->annotation_count
; ++i
)
5252 free_parameter(annotation_handles
[i
], FALSE
, FALSE
);
5254 HeapFree(GetProcessHeap(), 0, annotation_handles
);
5260 static HRESULT
d3dx9_parse_effect_pass(struct d3dx_pass
*pass
, const char *data
, const char **ptr
, D3DXHANDLE
*objects
)
5265 D3DXHANDLE
*annotation_handles
= NULL
;
5266 struct d3dx_state
*states
= NULL
;
5269 read_dword(ptr
, &offset
);
5270 TRACE("Pass name offset: %#x\n", offset
);
5271 hr
= d3dx9_parse_name(&name
, data
+ offset
);
5274 WARN("Failed to parse name\n");
5278 read_dword(ptr
, &pass
->annotation_count
);
5279 TRACE("Annotation count: %u\n", pass
->annotation_count
);
5281 read_dword(ptr
, &pass
->state_count
);
5282 TRACE("State count: %u\n", pass
->state_count
);
5284 if (pass
->annotation_count
)
5286 annotation_handles
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*annotation_handles
) * pass
->annotation_count
);
5287 if (!annotation_handles
)
5289 ERR("Out of memory\n");
5294 for (i
= 0; i
< pass
->annotation_count
; ++i
)
5296 struct d3dx_parameter
*annotation
;
5298 annotation
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*annotation
));
5301 ERR("Out of memory\n");
5306 annotation_handles
[i
] = get_parameter_handle(annotation
);
5308 hr
= d3dx9_parse_effect_annotation(annotation
, data
, ptr
, objects
);
5311 WARN("Failed to parse annotations\n");
5317 if (pass
->state_count
)
5319 states
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*states
) * pass
->state_count
);
5322 ERR("Out of memory\n");
5327 for (i
= 0; i
< pass
->state_count
; ++i
)
5329 hr
= d3dx9_parse_state(&states
[i
], data
, ptr
, objects
);
5332 WARN("Failed to parse annotations\n");
5339 pass
->annotation_handles
= annotation_handles
;
5340 pass
->states
= states
;
5346 if (annotation_handles
)
5348 for (i
= 0; i
< pass
->annotation_count
; ++i
)
5350 free_parameter(annotation_handles
[i
], FALSE
, FALSE
);
5352 HeapFree(GetProcessHeap(), 0, annotation_handles
);
5357 for (i
= 0; i
< pass
->state_count
; ++i
)
5359 free_state(&states
[i
]);
5361 HeapFree(GetProcessHeap(), 0, states
);
5364 HeapFree(GetProcessHeap(), 0, name
);
5369 static HRESULT
d3dx9_parse_effect_technique(struct d3dx_technique
*technique
, const char *data
, const char **ptr
, D3DXHANDLE
*objects
)
5374 D3DXHANDLE
*annotation_handles
= NULL
;
5375 D3DXHANDLE
*pass_handles
= NULL
;
5378 read_dword(ptr
, &offset
);
5379 TRACE("Technique name offset: %#x\n", offset
);
5380 hr
= d3dx9_parse_name(&name
, data
+ offset
);
5383 WARN("Failed to parse name\n");
5387 read_dword(ptr
, &technique
->annotation_count
);
5388 TRACE("Annotation count: %u\n", technique
->annotation_count
);
5390 read_dword(ptr
, &technique
->pass_count
);
5391 TRACE("Pass count: %u\n", technique
->pass_count
);
5393 if (technique
->annotation_count
)
5395 annotation_handles
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*annotation_handles
) * technique
->annotation_count
);
5396 if (!annotation_handles
)
5398 ERR("Out of memory\n");
5403 for (i
= 0; i
< technique
->annotation_count
; ++i
)
5405 struct d3dx_parameter
*annotation
;
5407 annotation
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*annotation
));
5410 ERR("Out of memory\n");
5415 annotation_handles
[i
] = get_parameter_handle(annotation
);
5417 hr
= d3dx9_parse_effect_annotation(annotation
, data
, ptr
, objects
);
5420 WARN("Failed to parse annotations\n");
5426 if (technique
->pass_count
)
5428 pass_handles
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*pass_handles
) * technique
->pass_count
);
5431 ERR("Out of memory\n");
5436 for (i
= 0; i
< technique
->pass_count
; ++i
)
5438 struct d3dx_pass
*pass
;
5440 pass
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*pass
));
5443 ERR("Out of memory\n");
5448 pass_handles
[i
] = get_pass_handle(pass
);
5450 hr
= d3dx9_parse_effect_pass(pass
, data
, ptr
, objects
);
5453 WARN("Failed to parse passes\n");
5459 technique
->name
= name
;
5460 technique
->pass_handles
= pass_handles
;
5461 technique
->annotation_handles
= annotation_handles
;
5469 for (i
= 0; i
< technique
->pass_count
; ++i
)
5471 free_pass(pass_handles
[i
]);
5473 HeapFree(GetProcessHeap(), 0, pass_handles
);
5476 if (annotation_handles
)
5478 for (i
= 0; i
< technique
->annotation_count
; ++i
)
5480 free_parameter(annotation_handles
[i
], FALSE
, FALSE
);
5482 HeapFree(GetProcessHeap(), 0, annotation_handles
);
5485 HeapFree(GetProcessHeap(), 0, name
);
5490 static HRESULT
d3dx9_parse_resource(struct ID3DXBaseEffectImpl
*base
, const char *data
, const char **ptr
)
5492 DWORD technique_index
;
5493 DWORD index
, state_index
, usage
, element_index
;
5494 struct d3dx_state
*state
;
5495 struct d3dx_parameter
*param
;
5496 HRESULT hr
= E_FAIL
;
5498 read_dword(ptr
, &technique_index
);
5499 TRACE("techn: %u\n", technique_index
);
5501 read_dword(ptr
, &index
);
5502 TRACE("index: %u\n", index
);
5504 read_dword(ptr
, &element_index
);
5505 TRACE("element_index: %u\n", element_index
);
5507 read_dword(ptr
, &state_index
);
5508 TRACE("state_index: %u\n", state_index
);
5510 read_dword(ptr
, &usage
);
5511 TRACE("usage: %u\n", usage
);
5513 if (technique_index
== 0xffffffff)
5515 struct d3dx_parameter
*parameter
;
5516 struct d3dx_sampler
*sampler
;
5518 if (index
>= base
->parameter_count
)
5520 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index
, base
->parameter_count
);
5524 parameter
= get_parameter_struct(base
->parameter_handles
[index
]);
5525 if (element_index
!= 0xffffffff)
5527 if (element_index
>= parameter
->element_count
&& parameter
->element_count
!= 0)
5529 FIXME("Index out of bounds: element_index %u >= element_count %u\n", element_index
, parameter
->element_count
);
5533 if (parameter
->element_count
!= 0) parameter
= get_parameter_struct(parameter
->member_handles
[element_index
]);
5536 sampler
= parameter
->data
;
5537 if (state_index
>= sampler
->state_count
)
5539 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index
, sampler
->state_count
);
5543 state
= &sampler
->states
[state_index
];
5547 struct d3dx_technique
*technique
;
5548 struct d3dx_pass
*pass
;
5550 if (technique_index
>= base
->technique_count
)
5552 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index
, base
->technique_count
);
5556 technique
= get_technique_struct(base
->technique_handles
[technique_index
]);
5557 if (index
>= technique
->pass_count
)
5559 FIXME("Index out of bounds: index %u >= pass_count %u\n", index
, technique
->pass_count
);
5563 pass
= get_pass_struct(technique
->pass_handles
[index
]);
5564 if (state_index
>= pass
->state_count
)
5566 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index
, pass
->state_count
);
5570 state
= &pass
->states
[state_index
];
5573 param
= get_parameter_struct(state
->parameter
);
5578 TRACE("usage 0: type %s\n", debug_d3dxparameter_type(param
->type
));
5579 switch (param
->type
)
5581 case D3DXPT_VERTEXSHADER
:
5582 case D3DXPT_PIXELSHADER
:
5583 state
->type
= ST_CONSTANT
;
5584 hr
= d3dx9_parse_data(param
, ptr
, base
->effect
->device
);
5591 state
->type
= ST_FXLC
;
5592 hr
= d3dx9_copy_data(param
->data
, ptr
);
5596 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
5602 state
->type
= ST_PARAMETER
;
5603 hr
= d3dx9_copy_data(param
->data
, ptr
);
5606 TRACE("Mapping to parameter %s\n", *(char **)param
->data
);
5611 FIXME("Unknown usage %x\n", usage
);
5618 static HRESULT
d3dx9_parse_effect(struct ID3DXBaseEffectImpl
*base
, const char *data
, UINT data_size
, DWORD start
)
5620 const char *ptr
= data
+ start
;
5621 D3DXHANDLE
*parameter_handles
= NULL
;
5622 D3DXHANDLE
*technique_handles
= NULL
;
5623 D3DXHANDLE
*objects
= NULL
;
5624 UINT stringcount
, objectcount
, resourcecount
;
5628 read_dword(&ptr
, &base
->parameter_count
);
5629 TRACE("Parameter count: %u\n", base
->parameter_count
);
5631 read_dword(&ptr
, &base
->technique_count
);
5632 TRACE("Technique count: %u\n", base
->technique_count
);
5634 skip_dword_unknown(&ptr
, 1);
5636 read_dword(&ptr
, &objectcount
);
5637 TRACE("Object count: %u\n", objectcount
);
5639 objects
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*objects
) * objectcount
);
5642 ERR("Out of memory\n");
5647 if (base
->parameter_count
)
5649 parameter_handles
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*parameter_handles
) * base
->parameter_count
);
5650 if (!parameter_handles
)
5652 ERR("Out of memory\n");
5657 for (i
= 0; i
< base
->parameter_count
; ++i
)
5659 struct d3dx_parameter
*parameter
;
5661 parameter
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*parameter
));
5664 ERR("Out of memory\n");
5669 parameter_handles
[i
] = get_parameter_handle(parameter
);
5671 hr
= d3dx9_parse_effect_parameter(parameter
, data
, &ptr
, objects
);
5674 WARN("Failed to parse parameter\n");
5680 if (base
->technique_count
)
5682 technique_handles
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*technique_handles
) * base
->technique_count
);
5683 if (!technique_handles
)
5685 ERR("Out of memory\n");
5690 for (i
= 0; i
< base
->technique_count
; ++i
)
5692 struct d3dx_technique
*technique
;
5694 technique
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*technique
));
5697 ERR("Out of memory\n");
5702 technique_handles
[i
] = get_technique_handle(technique
);
5704 hr
= d3dx9_parse_effect_technique(technique
, data
, &ptr
, objects
);
5707 WARN("Failed to parse technique\n");
5713 /* needed for further parsing */
5714 base
->technique_handles
= technique_handles
;
5715 base
->parameter_handles
= parameter_handles
;
5717 read_dword(&ptr
, &stringcount
);
5718 TRACE("String count: %u\n", stringcount
);
5720 read_dword(&ptr
, &resourcecount
);
5721 TRACE("Resource count: %u\n", resourcecount
);
5723 for (i
= 0; i
< stringcount
; ++i
)
5726 struct d3dx_parameter
*param
;
5728 read_dword(&ptr
, &id
);
5729 TRACE("Id: %u\n", id
);
5731 param
= get_parameter_struct(objects
[id
]);
5733 hr
= d3dx9_parse_data(param
, &ptr
, base
->effect
->device
);
5736 WARN("Failed to parse data\n");
5741 for (i
= 0; i
< resourcecount
; ++i
)
5743 TRACE("parse resource %u\n", i
);
5745 hr
= d3dx9_parse_resource(base
, data
, &ptr
);
5748 WARN("Failed to parse data\n");
5753 HeapFree(GetProcessHeap(), 0, objects
);
5759 if (technique_handles
)
5761 for (i
= 0; i
< base
->technique_count
; ++i
)
5763 free_technique(technique_handles
[i
]);
5765 HeapFree(GetProcessHeap(), 0, technique_handles
);
5768 if (parameter_handles
)
5770 for (i
= 0; i
< base
->parameter_count
; ++i
)
5772 free_parameter(parameter_handles
[i
], FALSE
, FALSE
);
5774 HeapFree(GetProcessHeap(), 0, parameter_handles
);
5777 base
->technique_handles
= NULL
;
5778 base
->parameter_handles
= NULL
;
5780 HeapFree(GetProcessHeap(), 0, objects
);
5785 static HRESULT
d3dx9_base_effect_init(struct ID3DXBaseEffectImpl
*base
,
5786 const char *data
, SIZE_T data_size
, struct ID3DXEffectImpl
*effect
)
5789 const char *ptr
= data
;
5792 TRACE("base %p, data %p, data_size %lu, effect %p\n", base
, data
, data_size
, effect
);
5794 base
->ID3DXBaseEffect_iface
.lpVtbl
= &ID3DXBaseEffect_Vtbl
;
5796 base
->effect
= effect
;
5798 read_dword(&ptr
, &tag
);
5799 TRACE("Tag: %x\n", tag
);
5801 if (tag
!= d3dx9_effect_version(9, 1))
5803 /* todo: compile hlsl ascii code */
5804 FIXME("HLSL ascii effects not supported, yet\n");
5806 /* Show the start of the shader for debugging info. */
5807 TRACE("effect:\n%s\n", debugstr_an(data
, data_size
> 40 ? 40 : data_size
));
5811 read_dword(&ptr
, &offset
);
5812 TRACE("Offset: %x\n", offset
);
5814 hr
= d3dx9_parse_effect(base
, ptr
, data_size
, offset
);
5817 FIXME("Failed to parse effect.\n");
5825 static HRESULT
d3dx9_effect_init(struct ID3DXEffectImpl
*effect
, LPDIRECT3DDEVICE9 device
,
5826 const char *data
, SIZE_T data_size
, LPD3DXEFFECTPOOL pool
)
5829 struct ID3DXBaseEffectImpl
*object
= NULL
;
5831 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect
, device
, data
, data_size
, pool
);
5833 effect
->ID3DXEffect_iface
.lpVtbl
= &ID3DXEffect_Vtbl
;
5836 if (pool
) pool
->lpVtbl
->AddRef(pool
);
5837 effect
->pool
= pool
;
5839 IDirect3DDevice9_AddRef(device
);
5840 effect
->device
= device
;
5842 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
5845 ERR("Out of memory\n");
5850 hr
= d3dx9_base_effect_init(object
, data
, data_size
, effect
);
5853 FIXME("Failed to parse effect.\n");
5857 effect
->base_effect
= &object
->ID3DXBaseEffect_iface
;
5859 /* initialize defaults - check because of unsupported ascii effects */
5860 if (object
->technique_handles
)
5862 effect
->active_technique
= object
->technique_handles
[0];
5863 effect
->active_pass
= NULL
;
5870 HeapFree(GetProcessHeap(), 0, object
);
5871 free_effect(effect
);
5876 HRESULT WINAPI
D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device
,
5879 CONST D3DXMACRO
* defines
,
5880 LPD3DXINCLUDE include
,
5881 LPCSTR skip_constants
,
5883 LPD3DXEFFECTPOOL pool
,
5884 LPD3DXEFFECT
* effect
,
5885 LPD3DXBUFFER
* compilation_errors
)
5887 struct ID3DXEffectImpl
*object
;
5890 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device
, srcdata
, srcdatalen
, defines
, include
,
5891 skip_constants
, flags
, pool
, effect
, compilation_errors
);
5893 if (!device
|| !srcdata
)
5894 return D3DERR_INVALIDCALL
;
5899 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5903 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
5906 ERR("Out of memory\n");
5907 return E_OUTOFMEMORY
;
5910 hr
= d3dx9_effect_init(object
, device
, srcdata
, srcdatalen
, pool
);
5913 WARN("Failed to initialize shader reflection\n");
5914 HeapFree(GetProcessHeap(), 0, object
);
5918 *effect
= &object
->ID3DXEffect_iface
;
5920 TRACE("Created ID3DXEffect %p\n", object
);
5925 HRESULT WINAPI
D3DXCreateEffect(LPDIRECT3DDEVICE9 device
,
5928 CONST D3DXMACRO
* defines
,
5929 LPD3DXINCLUDE include
,
5931 LPD3DXEFFECTPOOL pool
,
5932 LPD3DXEFFECT
* effect
,
5933 LPD3DXBUFFER
* compilation_errors
)
5935 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device
, srcdata
, srcdatalen
, defines
,
5936 include
, flags
, pool
, effect
, compilation_errors
);
5938 return D3DXCreateEffectEx(device
, srcdata
, srcdatalen
, defines
, include
, NULL
, flags
, pool
, effect
, compilation_errors
);
5941 static HRESULT
d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl
*compiler
, const char *data
, SIZE_T data_size
)
5944 struct ID3DXBaseEffectImpl
*object
= NULL
;
5946 TRACE("effect %p, data %p, data_size %lu\n", compiler
, data
, data_size
);
5948 compiler
->ID3DXEffectCompiler_iface
.lpVtbl
= &ID3DXEffectCompiler_Vtbl
;
5951 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
5954 ERR("Out of memory\n");
5959 hr
= d3dx9_base_effect_init(object
, data
, data_size
, NULL
);
5962 FIXME("Failed to parse effect.\n");
5966 compiler
->base_effect
= &object
->ID3DXBaseEffect_iface
;
5972 HeapFree(GetProcessHeap(), 0, object
);
5973 free_effect_compiler(compiler
);
5978 HRESULT WINAPI
D3DXCreateEffectCompiler(LPCSTR srcdata
,
5980 CONST D3DXMACRO
*defines
,
5981 LPD3DXINCLUDE include
,
5983 LPD3DXEFFECTCOMPILER
*compiler
,
5984 LPD3DXBUFFER
*parse_errors
)
5986 struct ID3DXEffectCompilerImpl
*object
;
5989 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5990 srcdata
, srcdatalen
, defines
, include
, flags
, compiler
, parse_errors
);
5992 if (!srcdata
|| !compiler
)
5994 WARN("Invalid arguments supplied\n");
5995 return D3DERR_INVALIDCALL
;
5998 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
6001 ERR("Out of memory\n");
6002 return E_OUTOFMEMORY
;
6005 hr
= d3dx9_effect_compiler_init(object
, srcdata
, srcdatalen
);
6008 WARN("Failed to initialize effect compiler\n");
6009 HeapFree(GetProcessHeap(), 0, object
);
6013 *compiler
= &object
->ID3DXEffectCompiler_iface
;
6015 TRACE("Created ID3DXEffectCompiler %p\n", object
);
6020 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl
;
6022 struct ID3DXEffectPoolImpl
6024 ID3DXEffectPool ID3DXEffectPool_iface
;
6028 static inline struct ID3DXEffectPoolImpl
*impl_from_ID3DXEffectPool(ID3DXEffectPool
*iface
)
6030 return CONTAINING_RECORD(iface
, struct ID3DXEffectPoolImpl
, ID3DXEffectPool_iface
);
6033 /*** IUnknown methods ***/
6034 static HRESULT WINAPI
ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool
*iface
, REFIID riid
, void **object
)
6036 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), object
);
6038 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
6039 IsEqualGUID(riid
, &IID_ID3DXEffectPool
))
6041 iface
->lpVtbl
->AddRef(iface
);
6046 WARN("Interface %s not found\n", debugstr_guid(riid
));
6048 return E_NOINTERFACE
;
6051 static ULONG WINAPI
ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool
*iface
)
6053 struct ID3DXEffectPoolImpl
*This
= impl_from_ID3DXEffectPool(iface
);
6055 TRACE("(%p)->(): AddRef from %u\n", This
, This
->ref
);
6057 return InterlockedIncrement(&This
->ref
);
6060 static ULONG WINAPI
ID3DXEffectPoolImpl_Release(ID3DXEffectPool
*iface
)
6062 struct ID3DXEffectPoolImpl
*This
= impl_from_ID3DXEffectPool(iface
);
6063 ULONG ref
= InterlockedDecrement(&This
->ref
);
6065 TRACE("(%p)->(): Release from %u\n", This
, ref
+ 1);
6068 HeapFree(GetProcessHeap(), 0, This
);
6073 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl
=
6075 /*** IUnknown methods ***/
6076 ID3DXEffectPoolImpl_QueryInterface
,
6077 ID3DXEffectPoolImpl_AddRef
,
6078 ID3DXEffectPoolImpl_Release
6081 HRESULT WINAPI
D3DXCreateEffectPool(LPD3DXEFFECTPOOL
*pool
)
6083 struct ID3DXEffectPoolImpl
*object
;
6085 TRACE("(%p)\n", pool
);
6088 return D3DERR_INVALIDCALL
;
6090 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
6093 ERR("Out of memory\n");
6094 return E_OUTOFMEMORY
;
6097 object
->ID3DXEffectPool_iface
.lpVtbl
= &ID3DXEffectPool_Vtbl
;
6100 *pool
= &object
->ID3DXEffectPool_iface
;
6105 HRESULT WINAPI
D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device
, LPCWSTR srcfile
,
6106 const D3DXMACRO
*defines
, LPD3DXINCLUDE include
, LPCSTR skipconstants
, DWORD flags
,
6107 LPD3DXEFFECTPOOL pool
, LPD3DXEFFECT
*effect
, LPD3DXBUFFER
*compilationerrors
)
6113 TRACE("(%s): relay\n", debugstr_w(srcfile
));
6115 if (!device
|| !srcfile
)
6116 return D3DERR_INVALIDCALL
;
6118 ret
= map_view_of_file(srcfile
, &buffer
, &size
);
6121 return D3DXERR_INVALIDDATA
;
6123 ret
= D3DXCreateEffectEx(device
, buffer
, size
, defines
, include
, skipconstants
, flags
, pool
, effect
, compilationerrors
);
6124 UnmapViewOfFile(buffer
);
6129 HRESULT WINAPI
D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device
, LPCSTR srcfile
,
6130 const D3DXMACRO
*defines
, LPD3DXINCLUDE include
, LPCSTR skipconstants
, DWORD flags
,
6131 LPD3DXEFFECTPOOL pool
, LPD3DXEFFECT
*effect
, LPD3DXBUFFER
*compilationerrors
)
6137 TRACE("(void): relay\n");
6140 return D3DERR_INVALIDCALL
;
6142 len
= MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, NULL
, 0);
6143 srcfileW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(*srcfileW
));
6144 MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, srcfileW
, len
);
6146 ret
= D3DXCreateEffectFromFileExW(device
, srcfileW
, defines
, include
, skipconstants
, flags
, pool
, effect
, compilationerrors
);
6147 HeapFree(GetProcessHeap(), 0, srcfileW
);
6152 HRESULT WINAPI
D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device
, LPCWSTR srcfile
,
6153 const D3DXMACRO
*defines
, LPD3DXINCLUDE include
, DWORD flags
, LPD3DXEFFECTPOOL pool
,
6154 LPD3DXEFFECT
*effect
, LPD3DXBUFFER
*compilationerrors
)
6156 TRACE("(void): relay\n");
6157 return D3DXCreateEffectFromFileExW(device
, srcfile
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
6160 HRESULT WINAPI
D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device
, LPCSTR srcfile
,
6161 const D3DXMACRO
*defines
, LPD3DXINCLUDE include
, DWORD flags
, LPD3DXEFFECTPOOL pool
,
6162 LPD3DXEFFECT
*effect
, LPD3DXBUFFER
*compilationerrors
)
6164 TRACE("(void): relay\n");
6165 return D3DXCreateEffectFromFileExA(device
, srcfile
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
6168 HRESULT WINAPI
D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device
, HMODULE srcmodule
, LPCWSTR srcresource
,
6169 const D3DXMACRO
*defines
, LPD3DXINCLUDE include
, LPCSTR skipconstants
, DWORD flags
,
6170 LPD3DXEFFECTPOOL pool
, LPD3DXEFFECT
*effect
, LPD3DXBUFFER
*compilationerrors
)
6174 TRACE("(%p, %s): relay\n", srcmodule
, debugstr_w(srcresource
));
6177 return D3DERR_INVALIDCALL
;
6179 resinfo
= FindResourceW(srcmodule
, srcresource
, (LPCWSTR
) RT_RCDATA
);
6187 ret
= load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
);
6190 return D3DXERR_INVALIDDATA
;
6192 return D3DXCreateEffectEx(device
, buffer
, size
, defines
, include
, skipconstants
, flags
, pool
, effect
, compilationerrors
);
6195 return D3DXERR_INVALIDDATA
;
6198 HRESULT WINAPI
D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device
, HMODULE srcmodule
, LPCSTR srcresource
,
6199 const D3DXMACRO
*defines
, LPD3DXINCLUDE include
, LPCSTR skipconstants
, DWORD flags
,
6200 LPD3DXEFFECTPOOL pool
, LPD3DXEFFECT
*effect
, LPD3DXBUFFER
*compilationerrors
)
6204 TRACE("(%p, %s): relay\n", srcmodule
, debugstr_a(srcresource
));
6207 return D3DERR_INVALIDCALL
;
6209 resinfo
= FindResourceA(srcmodule
, srcresource
, (LPCSTR
) RT_RCDATA
);
6217 ret
= load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
);
6220 return D3DXERR_INVALIDDATA
;
6222 return D3DXCreateEffectEx(device
, buffer
, size
, defines
, include
, skipconstants
, flags
, pool
, effect
, compilationerrors
);
6225 return D3DXERR_INVALIDDATA
;
6228 HRESULT WINAPI
D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device
, HMODULE srcmodule
, LPCWSTR srcresource
,
6229 const D3DXMACRO
*defines
, LPD3DXINCLUDE include
, DWORD flags
, LPD3DXEFFECTPOOL pool
,
6230 LPD3DXEFFECT
*effect
, LPD3DXBUFFER
*compilationerrors
)
6232 TRACE("(void): relay\n");
6233 return D3DXCreateEffectFromResourceExW(device
, srcmodule
, srcresource
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
6236 HRESULT WINAPI
D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device
, HMODULE srcmodule
, LPCSTR srcresource
,
6237 const D3DXMACRO
*defines
, LPD3DXINCLUDE include
, DWORD flags
, LPD3DXEFFECTPOOL pool
,
6238 LPD3DXEFFECT
*effect
, LPD3DXBUFFER
*compilationerrors
)
6240 TRACE("(void): relay\n");
6241 return D3DXCreateEffectFromResourceExA(device
, srcmodule
, srcresource
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
6244 HRESULT WINAPI
D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile
, const D3DXMACRO
*defines
, LPD3DXINCLUDE include
,
6245 DWORD flags
, LPD3DXEFFECTCOMPILER
*effectcompiler
, LPD3DXBUFFER
*parseerrors
)
6251 TRACE("(%s): relay\n", debugstr_w(srcfile
));
6254 return D3DERR_INVALIDCALL
;
6256 ret
= map_view_of_file(srcfile
, &buffer
, &size
);
6259 return D3DXERR_INVALIDDATA
;
6261 ret
= D3DXCreateEffectCompiler(buffer
, size
, defines
, include
, flags
, effectcompiler
, parseerrors
);
6262 UnmapViewOfFile(buffer
);
6267 HRESULT WINAPI
D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile
, const D3DXMACRO
*defines
, LPD3DXINCLUDE include
,
6268 DWORD flags
, LPD3DXEFFECTCOMPILER
*effectcompiler
, LPD3DXBUFFER
*parseerrors
)
6274 TRACE("(void): relay\n");
6277 return D3DERR_INVALIDCALL
;
6279 len
= MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, NULL
, 0);
6280 srcfileW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(*srcfileW
));
6281 MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, srcfileW
, len
);
6283 ret
= D3DXCreateEffectCompilerFromFileW(srcfileW
, defines
, include
, flags
, effectcompiler
, parseerrors
);
6284 HeapFree(GetProcessHeap(), 0, srcfileW
);
6289 HRESULT WINAPI
D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule
, LPCSTR srcresource
, const D3DXMACRO
*defines
,
6290 LPD3DXINCLUDE include
, DWORD flags
, LPD3DXEFFECTCOMPILER
*effectcompiler
, LPD3DXBUFFER
*parseerrors
)
6294 TRACE("(%p, %s): relay\n", srcmodule
, debugstr_a(srcresource
));
6296 resinfo
= FindResourceA(srcmodule
, srcresource
, (LPCSTR
) RT_RCDATA
);
6304 ret
= load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
);
6307 return D3DXERR_INVALIDDATA
;
6309 return D3DXCreateEffectCompiler(buffer
, size
, defines
, include
, flags
, effectcompiler
, parseerrors
);
6312 return D3DXERR_INVALIDDATA
;
6315 HRESULT WINAPI
D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule
, LPCWSTR srcresource
, const D3DXMACRO
*defines
,
6316 LPD3DXINCLUDE include
, DWORD flags
, LPD3DXEFFECTCOMPILER
*effectcompiler
, LPD3DXBUFFER
*parseerrors
)
6320 TRACE("(%p, %s): relay\n", srcmodule
, debugstr_w(srcresource
));
6322 resinfo
= FindResourceW(srcmodule
, srcresource
, (LPCWSTR
) RT_RCDATA
);
6330 ret
= load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
);
6333 return D3DXERR_INVALIDDATA
;
6335 return D3DXCreateEffectCompiler(buffer
, size
, defines
, include
, flags
, effectcompiler
, parseerrors
);
6338 return D3DXERR_INVALIDDATA
;