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_parameter_annotation_by_name(struct d3dx_parameter
*parameter
, 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"},
328 {SC_UNKNOWN
, 0, "UNKNOWN"},
330 {SC_NPATCHMODE
, 0, "NPatchMode"},
332 {SC_UNKNOWN
, 0, "UNKNOWN"},
334 {SC_TRANSFORM
, D3DTS_PROJECTION
, "D3DTS_PROJECTION"},
335 {SC_TRANSFORM
, D3DTS_VIEW
, "D3DTS_VIEW"},
336 {SC_TRANSFORM
, D3DTS_WORLD
, "D3DTS_WORLD"},
337 {SC_TRANSFORM
, D3DTS_TEXTURE0
, "D3DTS_TEXTURE0"},
339 {SC_MATERIAL
, MT_DIFFUSE
, "MaterialDiffuse"},
340 {SC_MATERIAL
, MT_AMBIENT
, "MaterialAmbient"}, /* 0x80 */
341 {SC_MATERIAL
, MT_SPECULAR
, "MaterialSpecular"},
342 {SC_MATERIAL
, MT_EMISSIVE
, "MaterialEmissive"},
343 {SC_MATERIAL
, MT_POWER
, "MaterialPower"},
345 {SC_LIGHT
, LT_TYPE
, "LightType"},
346 {SC_LIGHT
, LT_DIFFUSE
, "LightDiffuse"},
347 {SC_LIGHT
, LT_SPECULAR
, "LightSpecular"},
348 {SC_LIGHT
, LT_AMBIENT
, "LightAmbient"},
349 {SC_LIGHT
, LT_POSITION
, "LightPosition"},
350 {SC_LIGHT
, LT_DIRECTION
, "LightDirection"},
351 {SC_LIGHT
, LT_RANGE
, "LightRange"},
352 {SC_LIGHT
, LT_FALLOFF
, "LightFallOff"},
353 {SC_LIGHT
, LT_ATTENUATION0
, "LightAttenuation0"},
354 {SC_LIGHT
, LT_ATTENUATION1
, "LightAttenuation1"},
355 {SC_LIGHT
, LT_ATTENUATION2
, "LightAttenuation2"},
356 {SC_LIGHT
, LT_THETA
, "LightTheta"},
357 {SC_LIGHT
, LT_PHI
, "LightPhi"}, /* 0x90 */
359 {SC_LIGHTENABLE
, 0, "LightEnable"},
361 {SC_VERTEXSHADER
, 0, "Vertexshader"},
363 {SC_PIXELSHADER
, 0, "Pixelshader"},
364 /* Shader constants */
365 {SC_SHADERCONST
, SCT_VSFLOAT
, "VertexShaderConstantF"},
366 {SC_SHADERCONST
, SCT_VSBOOL
, "VertexShaderConstantB"},
367 {SC_SHADERCONST
, SCT_VSINT
, "VertexShaderConstantI"},
368 {SC_SHADERCONST
, SCT_VSFLOAT
, "VertexShaderConstant"},
369 {SC_SHADERCONST
, SCT_VSFLOAT
, "VertexShaderConstant1"},
370 {SC_SHADERCONST
, SCT_VSFLOAT
, "VertexShaderConstant2"},
371 {SC_SHADERCONST
, SCT_VSFLOAT
, "VertexShaderConstant3"},
372 {SC_SHADERCONST
, SCT_VSFLOAT
, "VertexShaderConstant4"},
373 {SC_SHADERCONST
, SCT_PSFLOAT
, "PixelShaderConstantF"},
374 {SC_SHADERCONST
, SCT_PSBOOL
, "PixelShaderConstantB"},
375 {SC_SHADERCONST
, SCT_PSINT
, "PixelShaderConstantI"},
376 {SC_SHADERCONST
, SCT_PSFLOAT
, "PixelShaderConstant"},
377 {SC_SHADERCONST
, SCT_PSFLOAT
, "PixelShaderConstant1"}, /* 0xa0 */
378 {SC_SHADERCONST
, SCT_PSFLOAT
, "PixelShaderConstant2"},
379 {SC_SHADERCONST
, SCT_PSFLOAT
, "PixelShaderConstant3"},
380 {SC_SHADERCONST
, SCT_PSFLOAT
, "PixelShaderConstant4"},
382 {SC_TEXTURE
, 0, "Texture"},
384 {SC_SAMPLERSTATE
, D3DSAMP_ADDRESSU
, "AddressU"},
385 {SC_SAMPLERSTATE
, D3DSAMP_ADDRESSV
, "AddressV"},
386 {SC_SAMPLERSTATE
, D3DSAMP_ADDRESSW
, "AddressW"},
387 {SC_SAMPLERSTATE
, D3DSAMP_BORDERCOLOR
, "BorderColor"},
388 {SC_SAMPLERSTATE
, D3DSAMP_MAGFILTER
, "MagFilter"},
389 {SC_SAMPLERSTATE
, D3DSAMP_MINFILTER
, "MinFilter"},
390 {SC_SAMPLERSTATE
, D3DSAMP_MIPFILTER
, "MipFilter"},
391 {SC_SAMPLERSTATE
, D3DSAMP_MIPMAPLODBIAS
, "MipMapLodBias"},
392 {SC_SAMPLERSTATE
, D3DSAMP_MAXMIPLEVEL
, "MaxMipLevel"},
393 {SC_SAMPLERSTATE
, D3DSAMP_MAXANISOTROPY
, "MaxAnisotropy"},
394 {SC_SAMPLERSTATE
, D3DSAMP_SRGBTEXTURE
, "SRGBTexture"},
395 {SC_SAMPLERSTATE
, D3DSAMP_ELEMENTINDEX
, "ElementIndex"}, /* 0xb0 */
396 {SC_SAMPLERSTATE
, D3DSAMP_DMAPOFFSET
, "DMAPOffset"},
398 {SC_SETSAMPLER
, 0, "Sampler"},
401 static inline void read_dword(const char **ptr
, DWORD
*d
)
403 memcpy(d
, *ptr
, sizeof(*d
));
407 static void skip_dword_unknown(const char **ptr
, unsigned int count
)
412 FIXME("Skipping %u unknown DWORDs:\n", count
);
413 for (i
= 0; i
< count
; ++i
)
416 FIXME("\t0x%08x\n", d
);
420 static inline struct d3dx_parameter
*get_parameter_struct(D3DXHANDLE handle
)
422 return (struct d3dx_parameter
*) handle
;
425 static inline struct d3dx_pass
*get_pass_struct(D3DXHANDLE handle
)
427 return (struct d3dx_pass
*) handle
;
430 static inline struct d3dx_technique
*get_technique_struct(D3DXHANDLE handle
)
432 return (struct d3dx_technique
*) handle
;
435 static inline D3DXHANDLE
get_parameter_handle(struct d3dx_parameter
*parameter
)
437 return (D3DXHANDLE
) parameter
;
440 static inline D3DXHANDLE
get_technique_handle(struct d3dx_technique
*technique
)
442 return (D3DXHANDLE
) technique
;
445 static inline D3DXHANDLE
get_pass_handle(struct d3dx_pass
*pass
)
447 return (D3DXHANDLE
) pass
;
450 static struct d3dx_technique
*is_valid_technique(struct ID3DXBaseEffectImpl
*base
, D3DXHANDLE technique
)
454 for (i
= 0; i
< base
->technique_count
; ++i
)
456 if (base
->technique_handles
[i
] == technique
)
458 return get_technique_struct(technique
);
465 static struct d3dx_pass
*is_valid_pass(struct ID3DXBaseEffectImpl
*base
, D3DXHANDLE pass
)
469 for (i
= 0; i
< base
->technique_count
; ++i
)
471 struct d3dx_technique
*technique
= get_technique_struct(base
->technique_handles
[i
]);
473 for (k
= 0; k
< technique
->pass_count
; ++k
)
475 if (technique
->pass_handles
[k
] == pass
)
477 return get_pass_struct(pass
);
485 static struct d3dx_parameter
*is_valid_sub_parameter(struct d3dx_parameter
*param
, D3DXHANDLE parameter
)
487 unsigned int i
, count
;
488 struct d3dx_parameter
*p
;
490 for (i
= 0; i
< param
->annotation_count
; ++i
)
492 if (param
->annotation_handles
[i
] == parameter
)
494 return get_parameter_struct(parameter
);
497 p
= is_valid_sub_parameter(get_parameter_struct(param
->annotation_handles
[i
]), parameter
);
501 if (param
->element_count
) count
= param
->element_count
;
502 else count
= param
->member_count
;
504 for (i
= 0; i
< count
; ++i
)
506 if (param
->member_handles
[i
] == parameter
)
508 return get_parameter_struct(parameter
);
511 p
= is_valid_sub_parameter(get_parameter_struct(param
->member_handles
[i
]), parameter
);
518 static struct d3dx_parameter
*is_valid_parameter(struct ID3DXBaseEffectImpl
*base
, D3DXHANDLE parameter
)
520 unsigned int i
, k
, m
;
521 struct d3dx_parameter
*p
;
523 for (i
= 0; i
< base
->parameter_count
; ++i
)
525 if (base
->parameter_handles
[i
] == parameter
)
527 return get_parameter_struct(parameter
);
530 p
= is_valid_sub_parameter(get_parameter_struct(base
->parameter_handles
[i
]), parameter
);
534 for (i
= 0; i
< base
->technique_count
; ++i
)
536 struct d3dx_technique
*technique
= get_technique_struct(base
->technique_handles
[i
]);
538 for (k
= 0; k
< technique
->pass_count
; ++k
)
540 struct d3dx_pass
*pass
= get_pass_struct(technique
->pass_handles
[k
]);
542 for (m
= 0; m
< pass
->annotation_count
; ++m
)
544 if (pass
->annotation_handles
[i
] == parameter
)
546 return get_parameter_struct(parameter
);
549 p
= is_valid_sub_parameter(get_parameter_struct(pass
->annotation_handles
[m
]), parameter
);
554 for (k
= 0; k
< technique
->annotation_count
; ++k
)
556 if (technique
->annotation_handles
[k
] == parameter
)
558 return get_parameter_struct(parameter
);
561 p
= is_valid_sub_parameter(get_parameter_struct(technique
->annotation_handles
[k
]), parameter
);
569 static inline struct d3dx_parameter
*get_valid_parameter(struct ID3DXBaseEffectImpl
*base
, D3DXHANDLE parameter
)
571 struct d3dx_parameter
*param
= is_valid_parameter(base
, parameter
);
573 if (!param
) param
= get_parameter_by_name(base
, NULL
, parameter
);
578 static void free_state(struct d3dx_state
*state
)
580 free_parameter_state(state
->parameter
, FALSE
, FALSE
, state
->type
);
583 static void free_sampler(struct d3dx_sampler
*sampler
)
587 for (i
= 0; i
< sampler
->state_count
; ++i
)
589 free_state(&sampler
->states
[i
]);
591 HeapFree(GetProcessHeap(), 0, sampler
->states
);
594 static void free_parameter(D3DXHANDLE handle
, BOOL element
, BOOL child
)
596 free_parameter_state(handle
, element
, child
, ST_CONSTANT
);
599 static void free_parameter_state(D3DXHANDLE handle
, BOOL element
, BOOL child
, enum STATE_TYPE st
)
602 struct d3dx_parameter
*param
= get_parameter_struct(handle
);
604 TRACE("Free parameter %p, name %s, type %s, child %s, state_type %x\n", param
, param
->name
,
605 debug_d3dxparameter_type(param
->type
), child
? "yes" : "no", st
);
612 if (param
->annotation_handles
)
614 for (i
= 0; i
< param
->annotation_count
; ++i
)
616 free_parameter(param
->annotation_handles
[i
], FALSE
, FALSE
);
618 HeapFree(GetProcessHeap(), 0, param
->annotation_handles
);
621 if (param
->member_handles
)
625 if (param
->element_count
) count
= param
->element_count
;
626 else count
= param
->member_count
;
628 for (i
= 0; i
< count
; ++i
)
630 free_parameter(param
->member_handles
[i
], param
->element_count
!= 0, TRUE
);
632 HeapFree(GetProcessHeap(), 0, param
->member_handles
);
635 if (param
->class == D3DXPC_OBJECT
&& !param
->element_count
)
640 HeapFree(GetProcessHeap(), 0, *(LPSTR
*)param
->data
);
641 if (!child
) HeapFree(GetProcessHeap(), 0, param
->data
);
645 case D3DXPT_TEXTURE1D
:
646 case D3DXPT_TEXTURE2D
:
647 case D3DXPT_TEXTURE3D
:
648 case D3DXPT_TEXTURECUBE
:
649 case D3DXPT_PIXELSHADER
:
650 case D3DXPT_VERTEXSHADER
:
651 if (st
== ST_CONSTANT
)
653 if (*(IUnknown
**)param
->data
) IUnknown_Release(*(IUnknown
**)param
->data
);
657 HeapFree(GetProcessHeap(), 0, *(LPSTR
*)param
->data
);
659 if (!child
) HeapFree(GetProcessHeap(), 0, param
->data
);
663 case D3DXPT_SAMPLER1D
:
664 case D3DXPT_SAMPLER2D
:
665 case D3DXPT_SAMPLER3D
:
666 case D3DXPT_SAMPLERCUBE
:
667 if (st
== ST_CONSTANT
)
669 free_sampler((struct d3dx_sampler
*)param
->data
);
673 HeapFree(GetProcessHeap(), 0, *(LPSTR
*)param
->data
);
675 /* samplers have always own data, so free that */
676 HeapFree(GetProcessHeap(), 0, param
->data
);
680 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
688 if (st
!= ST_CONSTANT
)
690 HeapFree(GetProcessHeap(), 0, *(LPSTR
*)param
->data
);
692 HeapFree(GetProcessHeap(), 0, param
->data
);
696 /* only the parent has to release name and semantic */
699 HeapFree(GetProcessHeap(), 0, param
->name
);
700 HeapFree(GetProcessHeap(), 0, param
->semantic
);
703 HeapFree(GetProcessHeap(), 0, param
);
706 static void free_pass(D3DXHANDLE handle
)
709 struct d3dx_pass
*pass
= get_pass_struct(handle
);
711 TRACE("Free pass %p\n", pass
);
718 if (pass
->annotation_handles
)
720 for (i
= 0; i
< pass
->annotation_count
; ++i
)
722 free_parameter(pass
->annotation_handles
[i
], FALSE
, FALSE
);
724 HeapFree(GetProcessHeap(), 0, pass
->annotation_handles
);
729 for (i
= 0; i
< pass
->state_count
; ++i
)
731 free_state(&pass
->states
[i
]);
733 HeapFree(GetProcessHeap(), 0, pass
->states
);
736 HeapFree(GetProcessHeap(), 0, pass
->name
);
737 HeapFree(GetProcessHeap(), 0, pass
);
740 static void free_technique(D3DXHANDLE handle
)
743 struct d3dx_technique
*technique
= get_technique_struct(handle
);
745 TRACE("Free technique %p\n", technique
);
752 if (technique
->annotation_handles
)
754 for (i
= 0; i
< technique
->annotation_count
; ++i
)
756 free_parameter(technique
->annotation_handles
[i
], FALSE
, FALSE
);
758 HeapFree(GetProcessHeap(), 0, technique
->annotation_handles
);
761 if (technique
->pass_handles
)
763 for (i
= 0; i
< technique
->pass_count
; ++i
)
765 free_pass(technique
->pass_handles
[i
]);
767 HeapFree(GetProcessHeap(), 0, technique
->pass_handles
);
770 HeapFree(GetProcessHeap(), 0, technique
->name
);
771 HeapFree(GetProcessHeap(), 0, technique
);
774 static void free_base_effect(struct ID3DXBaseEffectImpl
*base
)
778 TRACE("Free base effect %p\n", base
);
780 if (base
->parameter_handles
)
782 for (i
= 0; i
< base
->parameter_count
; ++i
)
784 free_parameter(base
->parameter_handles
[i
], FALSE
, FALSE
);
786 HeapFree(GetProcessHeap(), 0, base
->parameter_handles
);
789 if (base
->technique_handles
)
791 for (i
= 0; i
< base
->technique_count
; ++i
)
793 free_technique(base
->technique_handles
[i
]);
795 HeapFree(GetProcessHeap(), 0, base
->technique_handles
);
799 static void free_effect(struct ID3DXEffectImpl
*effect
)
801 TRACE("Free effect %p\n", effect
);
803 if (effect
->base_effect
)
805 effect
->base_effect
->lpVtbl
->Release(effect
->base_effect
);
810 effect
->pool
->lpVtbl
->Release(effect
->pool
);
815 IUnknown_Release(effect
->manager
);
818 IDirect3DDevice9_Release(effect
->device
);
821 static void free_effect_compiler(struct ID3DXEffectCompilerImpl
*compiler
)
823 TRACE("Free effect compiler %p\n", compiler
);
825 if (compiler
->base_effect
)
827 compiler
->base_effect
->lpVtbl
->Release(compiler
->base_effect
);
831 static INT
get_int(D3DXPARAMETER_TYPE type
, LPCVOID data
)
851 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type
));
858 inline static FLOAT
get_float(D3DXPARAMETER_TYPE type
, LPCVOID data
)
878 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type
));
885 static inline BOOL
get_bool(LPCVOID data
)
887 return (*(DWORD
*)data
) ? TRUE
: FALSE
;
890 static void set_number(LPVOID outdata
, D3DXPARAMETER_TYPE outtype
, LPCVOID indata
, D3DXPARAMETER_TYPE intype
)
892 TRACE("Changing from type %i to type %i\n", intype
, outtype
);
897 *(FLOAT
*)outdata
= get_float(intype
, indata
);
901 *(BOOL
*)outdata
= get_bool(indata
);
905 *(INT
*)outdata
= get_int(intype
, indata
);
909 FIXME("Error converting to type %i\n", outtype
);
915 static void get_vector(struct d3dx_parameter
*param
, D3DXVECTOR4
*vector
)
919 for (i
= 0; i
< 4; ++i
)
921 ((FLOAT
*)vector
)[i
] = i
< param
->columns
? get_float(param
->type
, (DWORD
*)param
->data
+ i
) : 0.0f
;
925 static void set_vector(struct d3dx_parameter
*param
, CONST D3DXVECTOR4
*vector
)
929 for (i
= 0; i
< param
->columns
; ++i
)
931 set_number((FLOAT
*)param
->data
+ i
, param
->type
, (FLOAT
*)vector
+ i
, D3DXPT_FLOAT
);
935 static void get_matrix(struct d3dx_parameter
*param
, D3DXMATRIX
*matrix
)
939 for (i
= 0; i
< 4; ++i
)
941 for (k
= 0; k
< 4; ++k
)
943 if ((i
< param
->rows
) && (k
< param
->columns
))
944 matrix
->u
.m
[i
][k
] = get_float(param
->type
, (FLOAT
*)param
->data
+ i
* param
->columns
+ k
);
946 matrix
->u
.m
[i
][k
] = 0.0f
;
951 static void set_matrix(struct d3dx_parameter
*param
, CONST D3DXMATRIX
*matrix
)
955 for (i
= 0; i
< 4; ++i
)
957 for (k
= 0; k
< 4; ++k
)
959 if ((i
< param
->rows
) && (k
< param
->columns
))
960 set_number((FLOAT
*)param
->data
+ i
* param
->columns
+ k
, param
->type
, &matrix
->u
.m
[i
][k
], D3DXPT_FLOAT
);
965 static struct d3dx_parameter
*get_parameter_element_by_name(struct d3dx_parameter
*parameter
, LPCSTR name
)
968 struct d3dx_parameter
*temp_parameter
;
971 TRACE("parameter %p, name %s\n", parameter
, debugstr_a(name
));
973 if (!name
|| !*name
) return parameter
;
975 element
= atoi(name
);
976 part
= strchr(name
, ']') + 1;
978 if (parameter
->element_count
> element
)
980 temp_parameter
= get_parameter_struct(parameter
->member_handles
[element
]);
985 return get_parameter_by_name(NULL
, temp_parameter
, part
);
988 return get_parameter_annotation_by_name(temp_parameter
, part
);
991 TRACE("Returning parameter %p\n", temp_parameter
);
992 return temp_parameter
;
995 FIXME("Unhandled case \"%c\"\n", *--part
);
1000 TRACE("Parameter not found\n");
1004 static struct d3dx_parameter
*get_parameter_annotation_by_name(struct d3dx_parameter
*parameter
, LPCSTR name
)
1007 struct d3dx_parameter
*temp_parameter
;
1010 TRACE("parameter %p, name %s\n", parameter
, debugstr_a(name
));
1012 if (!name
|| !*name
) return parameter
;
1014 length
= strcspn( name
, "[.@" );
1015 part
= name
+ length
;
1017 for (i
= 0; i
< parameter
->annotation_count
; ++i
)
1019 temp_parameter
= get_parameter_struct(parameter
->annotation_handles
[i
]);
1021 if (!strcmp(temp_parameter
->name
, name
))
1023 TRACE("Returning parameter %p\n", temp_parameter
);
1024 return temp_parameter
;
1026 else if (strlen(temp_parameter
->name
) == length
&& !strncmp(temp_parameter
->name
, name
, length
))
1031 return get_parameter_by_name(NULL
, temp_parameter
, part
);
1034 return get_parameter_element_by_name(temp_parameter
, part
);
1037 FIXME("Unhandled case \"%c\"\n", *--part
);
1043 TRACE("Parameter not found\n");
1047 static struct d3dx_parameter
*get_parameter_by_name(struct ID3DXBaseEffectImpl
*base
,
1048 struct d3dx_parameter
*parameter
, LPCSTR name
)
1050 UINT i
, count
, length
;
1051 struct d3dx_parameter
*temp_parameter
;
1052 D3DXHANDLE
*handles
;
1055 TRACE("base %p, parameter %p, name %s\n", base
, parameter
, debugstr_a(name
));
1057 if (!name
|| !*name
) return parameter
;
1061 count
= base
->parameter_count
;
1062 handles
= base
->parameter_handles
;
1066 count
= parameter
->member_count
;
1067 handles
= parameter
->member_handles
;
1070 length
= strcspn( name
, "[.@" );
1071 part
= name
+ length
;
1073 for (i
= 0; i
< count
; i
++)
1075 temp_parameter
= get_parameter_struct(handles
[i
]);
1077 if (!strcmp(temp_parameter
->name
, name
))
1079 TRACE("Returning parameter %p\n", temp_parameter
);
1080 return temp_parameter
;
1082 else if (strlen(temp_parameter
->name
) == length
&& !strncmp(temp_parameter
->name
, name
, length
))
1087 return get_parameter_by_name(NULL
, temp_parameter
, part
);
1090 return get_parameter_annotation_by_name(temp_parameter
, part
);
1093 return get_parameter_element_by_name(temp_parameter
, part
);
1096 FIXME("Unhandled case \"%c\"\n", *--part
);
1102 TRACE("Parameter not found\n");
1106 static inline DWORD
d3dx9_effect_version(DWORD major
, DWORD minor
)
1108 return (0xfeff0000 | ((major
) << 8) | (minor
));
1111 static inline struct ID3DXBaseEffectImpl
*impl_from_ID3DXBaseEffect(ID3DXBaseEffect
*iface
)
1113 return CONTAINING_RECORD(iface
, struct ID3DXBaseEffectImpl
, ID3DXBaseEffect_iface
);
1116 /*** IUnknown methods ***/
1117 static HRESULT WINAPI
ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect
*iface
, REFIID riid
, void **object
)
1119 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1121 TRACE("iface %p, riid %s, object %p\n", This
, debugstr_guid(riid
), object
);
1123 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
1124 IsEqualGUID(riid
, &IID_ID3DXBaseEffect
))
1126 This
->ID3DXBaseEffect_iface
.lpVtbl
->AddRef(iface
);
1131 ERR("Interface %s not found\n", debugstr_guid(riid
));
1133 return E_NOINTERFACE
;
1136 static ULONG WINAPI
ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect
*iface
)
1138 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1140 TRACE("iface %p: AddRef from %u\n", iface
, This
->ref
);
1142 return InterlockedIncrement(&This
->ref
);
1145 static ULONG WINAPI
ID3DXBaseEffectImpl_Release(ID3DXBaseEffect
*iface
)
1147 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1148 ULONG ref
= InterlockedDecrement(&This
->ref
);
1150 TRACE("iface %p: Release from %u\n", iface
, ref
+ 1);
1154 free_base_effect(This
);
1155 HeapFree(GetProcessHeap(), 0, This
);
1161 /*** ID3DXBaseEffect methods ***/
1162 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect
*iface
, D3DXEFFECT_DESC
*desc
)
1164 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1166 FIXME("iface %p, desc %p partial stub\n", This
, desc
);
1170 WARN("Invalid argument specified.\n");
1171 return D3DERR_INVALIDCALL
;
1174 /* Todo: add creator and function count */
1175 desc
->Creator
= NULL
;
1176 desc
->Functions
= 0;
1177 desc
->Parameters
= This
->parameter_count
;
1178 desc
->Techniques
= This
->technique_count
;
1183 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, D3DXPARAMETER_DESC
*desc
)
1185 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1186 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1188 TRACE("iface %p, parameter %p, desc %p\n", This
, parameter
, desc
);
1190 if (!desc
|| !param
)
1192 WARN("Invalid argument specified.\n");
1193 return D3DERR_INVALIDCALL
;
1196 desc
->Name
= param
->name
;
1197 desc
->Semantic
= param
->semantic
;
1198 desc
->Class
= param
->class;
1199 desc
->Type
= param
->type
;
1200 desc
->Rows
= param
->rows
;
1201 desc
->Columns
= param
->columns
;
1202 desc
->Elements
= param
->element_count
;
1203 desc
->Annotations
= param
->annotation_count
;
1204 desc
->StructMembers
= param
->member_count
;
1205 desc
->Flags
= param
->flags
;
1206 desc
->Bytes
= param
->bytes
;
1211 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect
*iface
, D3DXHANDLE technique
, D3DXTECHNIQUE_DESC
*desc
)
1213 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1214 struct d3dx_technique
*tech
= technique
? is_valid_technique(This
, technique
) : get_technique_struct(This
->technique_handles
[0]);
1216 TRACE("iface %p, technique %p, desc %p\n", This
, technique
, desc
);
1220 WARN("Invalid argument specified.\n");
1221 return D3DERR_INVALIDCALL
;
1224 desc
->Name
= tech
->name
;
1225 desc
->Passes
= tech
->pass_count
;
1226 desc
->Annotations
= tech
->annotation_count
;
1231 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect
*iface
, D3DXHANDLE pass
, D3DXPASS_DESC
*desc
)
1233 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1234 struct d3dx_pass
*p
= is_valid_pass(This
, pass
);
1236 TRACE("iface %p, pass %p, desc %p\n", This
, pass
, desc
);
1240 WARN("Invalid argument specified.\n");
1241 return D3DERR_INVALIDCALL
;
1244 desc
->Name
= p
->name
;
1245 desc
->Annotations
= p
->annotation_count
;
1247 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1248 desc
->pVertexShaderFunction
= NULL
;
1249 desc
->pPixelShaderFunction
= NULL
;
1254 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect
*iface
, D3DXHANDLE shader
, D3DXFUNCTION_DESC
*desc
)
1256 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1258 FIXME("iface %p, shader %p, desc %p stub\n", This
, shader
, desc
);
1263 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, UINT index
)
1265 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1266 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1268 TRACE("iface %p, parameter %p, index %u\n", This
, parameter
, index
);
1272 if (index
< This
->parameter_count
)
1274 TRACE("Returning parameter %p\n", This
->parameter_handles
[index
]);
1275 return This
->parameter_handles
[index
];
1280 if (param
&& !param
->element_count
&& index
< param
->member_count
)
1282 TRACE("Returning parameter %p\n", param
->member_handles
[index
]);
1283 return param
->member_handles
[index
];
1287 WARN("Invalid argument specified.\n");
1292 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPCSTR name
)
1294 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1295 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1298 TRACE("iface %p, parameter %p, name %s\n", This
, parameter
, debugstr_a(name
));
1302 handle
= get_parameter_handle(param
);
1303 TRACE("Returning parameter %p\n", handle
);
1307 handle
= get_parameter_handle(get_parameter_by_name(This
, param
, name
));
1308 TRACE("Returning parameter %p\n", handle
);
1313 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPCSTR semantic
)
1315 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1316 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1317 struct d3dx_parameter
*temp_param
;
1320 TRACE("iface %p, parameter %p, semantic %s\n", This
, parameter
, debugstr_a(semantic
));
1324 for (i
= 0; i
< This
->parameter_count
; ++i
)
1326 temp_param
= get_parameter_struct(This
->parameter_handles
[i
]);
1328 if (!temp_param
->semantic
)
1332 TRACE("Returning parameter %p\n", This
->parameter_handles
[i
]);
1333 return This
->parameter_handles
[i
];
1338 if (!strcasecmp(temp_param
->semantic
, semantic
))
1340 TRACE("Returning parameter %p\n", This
->parameter_handles
[i
]);
1341 return This
->parameter_handles
[i
];
1347 for (i
= 0; i
< param
->member_count
; ++i
)
1349 temp_param
= get_parameter_struct(param
->member_handles
[i
]);
1351 if (!temp_param
->semantic
)
1355 TRACE("Returning parameter %p\n", param
->member_handles
[i
]);
1356 return param
->member_handles
[i
];
1361 if (!strcasecmp(temp_param
->semantic
, semantic
))
1363 TRACE("Returning parameter %p\n", param
->member_handles
[i
]);
1364 return param
->member_handles
[i
];
1369 WARN("Invalid argument specified\n");
1374 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, UINT index
)
1376 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1377 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1379 TRACE("iface %p, parameter %p, index %u\n", This
, parameter
, index
);
1383 if (index
< This
->parameter_count
)
1385 TRACE("Returning parameter %p\n", This
->parameter_handles
[index
]);
1386 return This
->parameter_handles
[index
];
1391 if (index
< param
->element_count
)
1393 TRACE("Returning parameter %p\n", param
->member_handles
[index
]);
1394 return param
->member_handles
[index
];
1398 WARN("Invalid argument specified\n");
1403 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect
*iface
, UINT index
)
1405 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1407 TRACE("iface %p, index %u\n", This
, index
);
1409 if (index
>= This
->technique_count
)
1411 WARN("Invalid argument specified.\n");
1415 TRACE("Returning technique %p\n", This
->technique_handles
[index
]);
1417 return This
->technique_handles
[index
];
1420 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect
*iface
, LPCSTR name
)
1422 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1425 TRACE("iface %p, name %s stub\n", This
, debugstr_a(name
));
1429 WARN("Invalid argument specified.\n");
1433 for (i
= 0; i
< This
->technique_count
; ++i
)
1435 struct d3dx_technique
*tech
= get_technique_struct(This
->technique_handles
[i
]);
1437 if (!strcmp(tech
->name
, name
))
1439 TRACE("Returning technique %p\n", This
->technique_handles
[i
]);
1440 return This
->technique_handles
[i
];
1444 WARN("Invalid argument specified.\n");
1449 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect
*iface
, D3DXHANDLE technique
, UINT index
)
1451 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1452 struct d3dx_technique
*tech
= is_valid_technique(This
, technique
);
1454 TRACE("iface %p, technique %p, index %u\n", This
, technique
, index
);
1456 if (!tech
) tech
= get_technique_struct(iface
->lpVtbl
->GetTechniqueByName(iface
, technique
));
1458 if (tech
&& index
< tech
->pass_count
)
1460 TRACE("Returning pass %p\n", tech
->pass_handles
[index
]);
1461 return tech
->pass_handles
[index
];
1464 WARN("Invalid argument specified.\n");
1469 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect
*iface
, D3DXHANDLE technique
, LPCSTR name
)
1471 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1472 struct d3dx_technique
*tech
= is_valid_technique(This
, technique
);
1474 TRACE("iface %p, technique %p, name %s\n", This
, technique
, debugstr_a(name
));
1476 if (!tech
) tech
= get_technique_struct(iface
->lpVtbl
->GetTechniqueByName(iface
, technique
));
1482 for (i
= 0; i
< tech
->pass_count
; ++i
)
1484 struct d3dx_pass
*pass
= get_pass_struct(tech
->pass_handles
[i
]);
1486 if (!strcmp(pass
->name
, name
))
1488 TRACE("Returning pass %p\n", tech
->pass_handles
[i
]);
1489 return tech
->pass_handles
[i
];
1494 WARN("Invalid argument specified.\n");
1499 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect
*iface
, UINT index
)
1501 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1503 FIXME("iface %p, index %u stub\n", This
, index
);
1508 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect
*iface
, LPCSTR name
)
1510 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1512 FIXME("iface %p, name %s stub\n", This
, debugstr_a(name
));
1517 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect
*iface
, D3DXHANDLE object
, UINT index
)
1519 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1520 struct d3dx_parameter
*param
= get_valid_parameter(This
, object
);
1521 struct d3dx_pass
*pass
= is_valid_pass(This
, object
);
1522 struct d3dx_technique
*technique
= is_valid_technique(This
, object
);
1523 UINT annotation_count
= 0;
1524 D3DXHANDLE
*annotation_handles
= NULL
;
1526 FIXME("iface %p, object %p, index %u partial stub\n", This
, object
, index
);
1530 annotation_count
= pass
->annotation_count
;
1531 annotation_handles
= pass
->annotation_handles
;
1535 annotation_count
= technique
->annotation_count
;
1536 annotation_handles
= technique
->annotation_handles
;
1540 annotation_count
= param
->annotation_count
;
1541 annotation_handles
= param
->annotation_handles
;
1543 /* Todo: add funcs */
1545 if (index
< annotation_count
)
1547 TRACE("Returning parameter %p\n", annotation_handles
[index
]);
1548 return annotation_handles
[index
];
1551 WARN("Invalid argument specified\n");
1556 static D3DXHANDLE WINAPI
ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect
*iface
, D3DXHANDLE object
, LPCSTR name
)
1558 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1559 struct d3dx_parameter
*param
= get_valid_parameter(This
, object
);
1560 struct d3dx_pass
*pass
= is_valid_pass(This
, object
);
1561 struct d3dx_technique
*technique
= is_valid_technique(This
, object
);
1562 UINT annotation_count
= 0, i
;
1563 D3DXHANDLE
*annotation_handles
= NULL
;
1565 FIXME("iface %p, object %p, name %s partial stub\n", This
, object
, debugstr_a(name
));
1569 WARN("Invalid argument specified\n");
1575 annotation_count
= pass
->annotation_count
;
1576 annotation_handles
= pass
->annotation_handles
;
1580 annotation_count
= technique
->annotation_count
;
1581 annotation_handles
= technique
->annotation_handles
;
1585 annotation_count
= param
->annotation_count
;
1586 annotation_handles
= param
->annotation_handles
;
1588 /* Todo: add funcs */
1590 for (i
= 0; i
< annotation_count
; i
++)
1592 struct d3dx_parameter
*anno
= get_parameter_struct(annotation_handles
[i
]);
1594 if (!strcmp(anno
->name
, name
))
1596 TRACE("Returning parameter %p\n", anno
);
1597 return get_parameter_handle(anno
);
1601 WARN("Invalid argument specified\n");
1606 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPCVOID data
, UINT bytes
)
1608 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1609 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1611 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This
, parameter
, data
, bytes
);
1615 WARN("Invalid parameter %p specified\n", parameter
);
1616 return D3DERR_INVALIDCALL
;
1619 /* samplers don't touch data */
1620 if (param
->class == D3DXPC_OBJECT
&& (param
->type
== D3DXPT_SAMPLER
1621 || param
->type
== D3DXPT_SAMPLER1D
|| param
->type
== D3DXPT_SAMPLER2D
1622 || param
->type
== D3DXPT_SAMPLER3D
|| param
->type
== D3DXPT_SAMPLERCUBE
))
1624 TRACE("Sampler: returning E_FAIL\n");
1628 if (data
&& param
->bytes
>= bytes
)
1630 switch (param
->type
)
1636 TRACE("Copy %u bytes\n", bytes
);
1637 memcpy(param
->data
, data
, bytes
);
1641 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
1648 WARN("Invalid argument specified\n");
1650 return D3DERR_INVALIDCALL
;
1653 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPVOID data
, UINT bytes
)
1655 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1656 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1658 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This
, parameter
, data
, bytes
);
1662 WARN("Invalid parameter %p specified\n", parameter
);
1663 return D3DERR_INVALIDCALL
;
1666 /* samplers don't touch data */
1667 if (param
->class == D3DXPC_OBJECT
&& (param
->type
== D3DXPT_SAMPLER
1668 || param
->type
== D3DXPT_SAMPLER1D
|| param
->type
== D3DXPT_SAMPLER2D
1669 || param
->type
== D3DXPT_SAMPLER3D
|| param
->type
== D3DXPT_SAMPLERCUBE
))
1671 TRACE("Sampler: returning E_FAIL\n");
1675 if (data
&& param
->bytes
<= bytes
)
1677 TRACE("Type %s\n", debug_d3dxparameter_type(param
->type
));
1679 switch (param
->type
)
1688 case D3DXPT_VERTEXSHADER
:
1689 case D3DXPT_PIXELSHADER
:
1690 case D3DXPT_TEXTURE
:
1691 case D3DXPT_TEXTURE1D
:
1692 case D3DXPT_TEXTURE2D
:
1693 case D3DXPT_TEXTURE3D
:
1694 case D3DXPT_TEXTURECUBE
:
1698 for (i
= 0; i
< (param
->element_count
? param
->element_count
: 1); ++i
)
1700 IUnknown
*unk
= ((IUnknown
**)param
->data
)[i
];
1701 if (unk
) IUnknown_AddRef(unk
);
1707 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
1711 TRACE("Copy %u bytes\n", param
->bytes
);
1712 memcpy(data
, param
->data
, param
->bytes
);
1716 WARN("Invalid argument specified\n");
1718 return D3DERR_INVALIDCALL
;
1721 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, BOOL b
)
1723 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1724 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1726 TRACE("iface %p, parameter %p, b %s\n", This
, parameter
, b
? "TRUE" : "FALSE");
1728 if (param
&& !param
->element_count
&& param
->rows
== 1 && param
->columns
== 1)
1730 set_number(param
->data
, param
->type
, &b
, D3DXPT_BOOL
);
1734 WARN("Invalid argument specified\n");
1736 return D3DERR_INVALIDCALL
;
1739 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, BOOL
*b
)
1741 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1742 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1744 TRACE("iface %p, parameter %p, b %p\n", This
, parameter
, b
);
1746 if (b
&& param
&& !param
->element_count
&& param
->rows
== 1 && param
->columns
== 1)
1748 *b
= get_bool(param
->data
);
1749 TRACE("Returning %s\n", *b
? "TRUE" : "FALSE");
1753 WARN("Invalid argument specified\n");
1755 return D3DERR_INVALIDCALL
;
1758 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST BOOL
*b
, UINT count
)
1760 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1761 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1763 TRACE("iface %p, parameter %p, b %p, count %u\n", This
, parameter
, b
, count
);
1767 UINT i
, size
= min(count
, param
->bytes
/ sizeof(DWORD
));
1769 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
1771 switch (param
->class)
1775 case D3DXPC_MATRIX_ROWS
:
1776 for (i
= 0; i
< size
; ++i
)
1778 set_number((DWORD
*)param
->data
+ i
, param
->type
, &b
[i
], D3DXPT_BOOL
);
1787 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
1792 WARN("Invalid argument specified\n");
1794 return D3DERR_INVALIDCALL
;
1797 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, BOOL
*b
, UINT count
)
1799 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1800 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1802 TRACE("iface %p, parameter %p, b %p, count %u\n", This
, parameter
, b
, count
);
1804 if (b
&& param
&& (param
->class == D3DXPC_SCALAR
1805 || param
->class == D3DXPC_VECTOR
1806 || param
->class == D3DXPC_MATRIX_ROWS
1807 || param
->class == D3DXPC_MATRIX_COLUMNS
))
1809 UINT i
, size
= min(count
, param
->bytes
/ sizeof(DWORD
));
1811 for (i
= 0; i
< size
; ++i
)
1813 b
[i
] = get_bool((DWORD
*)param
->data
+ i
);
1818 WARN("Invalid argument specified\n");
1820 return D3DERR_INVALIDCALL
;
1823 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, INT n
)
1825 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1826 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1828 TRACE("iface %p, parameter %p, n %i\n", This
, parameter
, n
);
1830 if (param
&& !param
->element_count
)
1832 if (param
->rows
== 1 && param
->columns
== 1)
1834 set_number(param
->data
, param
->type
, &n
, D3DXPT_INT
);
1839 * Split the value, if parameter is a vector with dimension 3 or 4.
1841 if (param
->type
== D3DXPT_FLOAT
&&
1842 ((param
->class == D3DXPC_VECTOR
&& param
->columns
!= 2) ||
1843 (param
->class == D3DXPC_MATRIX_ROWS
&& param
->rows
!= 2 && param
->columns
== 1)))
1845 TRACE("Vector fixup\n");
1847 *(FLOAT
*)param
->data
= ((n
& 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE
;
1848 ((FLOAT
*)param
->data
)[1] = ((n
& 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE
;
1849 ((FLOAT
*)param
->data
)[2] = (n
& 0xff) * INT_FLOAT_MULTI_INVERSE
;
1850 if (param
->rows
* param
->columns
> 3)
1852 ((FLOAT
*)param
->data
)[3] = ((n
& 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE
;
1858 WARN("Invalid argument specified\n");
1860 return D3DERR_INVALIDCALL
;
1863 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, INT
*n
)
1865 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1866 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1868 TRACE("iface %p, parameter %p, n %p\n", This
, parameter
, n
);
1870 if (n
&& param
&& !param
->element_count
)
1872 if (param
->columns
== 1 && param
->rows
== 1)
1874 *n
= get_int(param
->type
, param
->data
);
1875 TRACE("Returning %i\n", *n
);
1879 if (param
->type
== D3DXPT_FLOAT
&&
1880 ((param
->class == D3DXPC_VECTOR
&& param
->columns
!= 2)
1881 || (param
->class == D3DXPC_MATRIX_ROWS
&& param
->rows
!= 2 && param
->columns
== 1)))
1883 TRACE("Vector fixup\n");
1885 /* all components (3,4) are clamped (0,255) and put in the INT */
1886 *n
= (INT
)(min(max(0.0f
, *((FLOAT
*)param
->data
+ 2)), 1.0f
) * INT_FLOAT_MULTI
);
1887 *n
+= ((INT
)(min(max(0.0f
, *((FLOAT
*)param
->data
+ 1)), 1.0f
) * INT_FLOAT_MULTI
)) << 8;
1888 *n
+= ((INT
)(min(max(0.0f
, *((FLOAT
*)param
->data
+ 0)), 1.0f
) * INT_FLOAT_MULTI
)) << 16;
1889 if (param
->columns
* param
->rows
> 3)
1891 *n
+= ((INT
)(min(max(0.0f
, *((FLOAT
*)param
->data
+ 3)), 1.0f
) * INT_FLOAT_MULTI
)) << 24;
1894 TRACE("Returning %i\n", *n
);
1899 WARN("Invalid argument specified\n");
1901 return D3DERR_INVALIDCALL
;
1904 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST INT
*n
, UINT count
)
1906 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1907 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1909 TRACE("iface %p, parameter %p, n %p, count %u\n", This
, parameter
, n
, count
);
1913 UINT i
, size
= min(count
, param
->bytes
/ sizeof(DWORD
));
1915 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
1917 switch (param
->class)
1921 case D3DXPC_MATRIX_ROWS
:
1922 for (i
= 0; i
< size
; ++i
)
1924 set_number((DWORD
*)param
->data
+ i
, param
->type
, &n
[i
], D3DXPT_INT
);
1933 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
1938 WARN("Invalid argument specified\n");
1940 return D3DERR_INVALIDCALL
;
1943 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, INT
*n
, UINT count
)
1945 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1946 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1948 TRACE("iface %p, parameter %p, n %p, count %u\n", This
, parameter
, n
, count
);
1950 if (n
&& param
&& (param
->class == D3DXPC_SCALAR
1951 || param
->class == D3DXPC_VECTOR
1952 || param
->class == D3DXPC_MATRIX_ROWS
1953 || param
->class == D3DXPC_MATRIX_COLUMNS
))
1955 UINT i
, size
= min(count
, param
->bytes
/ sizeof(DWORD
));
1957 for (i
= 0; i
< size
; ++i
)
1959 n
[i
] = get_int(param
->type
, (DWORD
*)param
->data
+ i
);
1964 WARN("Invalid argument specified\n");
1966 return D3DERR_INVALIDCALL
;
1969 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, FLOAT f
)
1971 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1972 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1974 TRACE("iface %p, parameter %p, f %f\n", This
, parameter
, f
);
1976 if (param
&& !param
->element_count
&& param
->rows
== 1 && param
->columns
== 1)
1978 set_number((DWORD
*)param
->data
, param
->type
, &f
, D3DXPT_FLOAT
);
1982 WARN("Invalid argument specified\n");
1984 return D3DERR_INVALIDCALL
;
1987 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, FLOAT
*f
)
1989 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
1990 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
1992 TRACE("iface %p, parameter %p, f %p\n", This
, parameter
, f
);
1994 if (f
&& param
&& !param
->element_count
&& param
->columns
== 1 && param
->rows
== 1)
1996 *f
= get_float(param
->type
, (DWORD
*)param
->data
);
1997 TRACE("Returning %f\n", *f
);
2001 WARN("Invalid argument specified\n");
2003 return D3DERR_INVALIDCALL
;
2006 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST FLOAT
*f
, UINT count
)
2008 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2009 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2011 TRACE("iface %p, parameter %p, f %p, count %u\n", This
, parameter
, f
, count
);
2015 UINT i
, size
= min(count
, param
->bytes
/ sizeof(DWORD
));
2017 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2019 switch (param
->class)
2023 case D3DXPC_MATRIX_ROWS
:
2024 for (i
= 0; i
< size
; ++i
)
2026 set_number((DWORD
*)param
->data
+ i
, param
->type
, &f
[i
], D3DXPT_FLOAT
);
2035 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2040 WARN("Invalid argument specified\n");
2042 return D3DERR_INVALIDCALL
;
2045 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, FLOAT
*f
, UINT count
)
2047 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2048 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2050 TRACE("iface %p, parameter %p, f %p, count %u\n", This
, parameter
, f
, count
);
2052 if (f
&& param
&& (param
->class == D3DXPC_SCALAR
2053 || param
->class == D3DXPC_VECTOR
2054 || param
->class == D3DXPC_MATRIX_ROWS
2055 || param
->class == D3DXPC_MATRIX_COLUMNS
))
2057 UINT i
, size
= min(count
, param
->bytes
/ sizeof(DWORD
));
2059 for (i
= 0; i
< size
; ++i
)
2061 f
[i
] = get_float(param
->type
, (DWORD
*)param
->data
+ i
);
2066 WARN("Invalid argument specified\n");
2068 return D3DERR_INVALIDCALL
;
2071 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXVECTOR4
*vector
)
2073 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2074 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2076 TRACE("iface %p, parameter %p, vector %p\n", This
, parameter
, vector
);
2078 if (param
&& !param
->element_count
)
2080 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2082 switch (param
->class)
2086 if (param
->type
== D3DXPT_INT
&& param
->bytes
== 4)
2090 TRACE("INT fixup\n");
2091 tmp
= (DWORD
)(max(min(vector
->z
, 1.0f
), 0.0f
) * INT_FLOAT_MULTI
);
2092 tmp
+= ((DWORD
)(max(min(vector
->y
, 1.0f
), 0.0f
) * INT_FLOAT_MULTI
)) << 8;
2093 tmp
+= ((DWORD
)(max(min(vector
->x
, 1.0f
), 0.0f
) * INT_FLOAT_MULTI
)) << 16;
2094 tmp
+= ((DWORD
)(max(min(vector
->w
, 1.0f
), 0.0f
) * INT_FLOAT_MULTI
)) << 24;
2096 *(INT
*)param
->data
= tmp
;
2099 set_vector(param
, vector
);
2102 case D3DXPC_MATRIX_ROWS
:
2108 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2113 WARN("Invalid argument specified\n");
2115 return D3DERR_INVALIDCALL
;
2118 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, D3DXVECTOR4
*vector
)
2120 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2121 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2123 TRACE("iface %p, parameter %p, vector %p\n", This
, parameter
, vector
);
2125 if (vector
&& param
&& !param
->element_count
)
2127 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2129 switch (param
->class)
2133 if (param
->type
== D3DXPT_INT
&& param
->bytes
== 4)
2135 TRACE("INT fixup\n");
2136 vector
->x
= (((*(INT
*)param
->data
) & 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE
;
2137 vector
->y
= (((*(INT
*)param
->data
) & 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE
;
2138 vector
->z
= ((*(INT
*)param
->data
) & 0xff) * INT_FLOAT_MULTI_INVERSE
;
2139 vector
->w
= (((*(INT
*)param
->data
) & 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE
;
2142 get_vector(param
, vector
);
2145 case D3DXPC_MATRIX_ROWS
:
2151 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2156 WARN("Invalid argument specified\n");
2158 return D3DERR_INVALIDCALL
;
2161 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXVECTOR4
*vector
, UINT count
)
2163 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2164 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2166 TRACE("iface %p, parameter %p, vector %p, count %u stub\n", This
, parameter
, vector
, count
);
2168 if (param
&& param
->element_count
&& param
->element_count
>= count
)
2172 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2174 switch (param
->class)
2177 for (i
= 0; i
< count
; ++i
)
2179 set_vector(get_parameter_struct(param
->member_handles
[i
]), &vector
[i
]);
2184 case D3DXPC_MATRIX_ROWS
:
2190 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2195 WARN("Invalid argument specified\n");
2197 return D3DERR_INVALIDCALL
;
2200 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, D3DXVECTOR4
*vector
, UINT count
)
2202 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2203 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2205 TRACE("iface %p, parameter %p, vector %p, count %u\n", This
, parameter
, vector
, count
);
2207 if (!count
) return D3D_OK
;
2209 if (vector
&& param
&& count
<= param
->element_count
)
2213 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2215 switch (param
->class)
2218 for (i
= 0; i
< count
; ++i
)
2220 get_vector(get_parameter_struct(param
->member_handles
[i
]), &vector
[i
]);
2225 case D3DXPC_MATRIX_ROWS
:
2231 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2236 WARN("Invalid argument specified\n");
2238 return D3DERR_INVALIDCALL
;
2241 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
)
2243 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2244 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2246 TRACE("iface %p, parameter %p, matrix %p\n", This
, parameter
, matrix
);
2248 if (param
&& !param
->element_count
)
2250 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2252 switch (param
->class)
2254 case D3DXPC_MATRIX_ROWS
:
2255 set_matrix(param
, matrix
);
2265 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2270 WARN("Invalid argument specified\n");
2272 return D3DERR_INVALIDCALL
;
2275 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
2277 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2278 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2280 TRACE("iface %p, parameter %p, matrix %p\n", This
, parameter
, matrix
);
2282 if (matrix
&& param
&& !param
->element_count
)
2284 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2286 switch (param
->class)
2288 case D3DXPC_MATRIX_ROWS
:
2289 get_matrix(param
, matrix
);
2299 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2304 WARN("Invalid argument specified\n");
2306 return D3DERR_INVALIDCALL
;
2309 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
, UINT count
)
2311 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2312 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2314 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This
, parameter
, matrix
, count
);
2316 if (param
&& param
->element_count
>= count
)
2320 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2322 switch (param
->class)
2324 case D3DXPC_MATRIX_ROWS
:
2325 for (i
= 0; i
< count
; ++i
)
2327 set_matrix(get_parameter_struct(param
->member_handles
[i
]), &matrix
[i
]);
2338 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2343 WARN("Invalid argument specified\n");
2345 return D3DERR_INVALIDCALL
;
2348 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
2350 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2351 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2353 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This
, parameter
, matrix
, count
);
2355 if (!count
) return D3D_OK
;
2357 if (matrix
&& param
&& count
<= param
->element_count
)
2361 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2363 switch (param
->class)
2365 case D3DXPC_MATRIX_ROWS
:
2366 for (i
= 0; i
< count
; ++i
)
2368 get_matrix(get_parameter_struct(param
->member_handles
[i
]), &matrix
[i
]);
2379 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2384 WARN("Invalid argument specified\n");
2386 return D3DERR_INVALIDCALL
;
2389 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
**matrix
, UINT count
)
2391 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2393 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This
, parameter
, matrix
, count
);
2398 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
2400 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2402 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This
, parameter
, matrix
, count
);
2407 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
)
2409 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2410 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2413 TRACE("iface %p, parameter %p, matrix %p\n", This
, parameter
, matrix
);
2415 if (param
&& !param
->element_count
)
2417 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2419 switch (param
->class)
2421 case D3DXPC_MATRIX_ROWS
:
2422 set_matrix(param
, D3DXMatrixTranspose(&m
, matrix
));
2432 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2437 WARN("Invalid argument specified\n");
2439 return D3DERR_INVALIDCALL
;
2442 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
2444 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2445 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2448 TRACE("iface %p, parameter %p, matrix %p\n", This
, parameter
, matrix
);
2450 if (matrix
&& param
&& !param
->element_count
)
2452 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2454 switch (param
->class)
2458 get_matrix(param
, matrix
);
2461 case D3DXPC_MATRIX_ROWS
:
2462 get_matrix(param
, &m
);
2463 D3DXMatrixTranspose(matrix
, &m
);
2471 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2476 WARN("Invalid argument specified\n");
2478 return D3DERR_INVALIDCALL
;
2481 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
, UINT count
)
2483 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2484 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2487 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This
, parameter
, matrix
, count
);
2489 if (param
&& param
->element_count
>= count
)
2493 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2495 switch (param
->class)
2497 case D3DXPC_MATRIX_ROWS
:
2498 for (i
= 0; i
< count
; ++i
)
2500 set_matrix(get_parameter_struct(param
->member_handles
[i
]), D3DXMatrixTranspose(&m
, &matrix
[i
]));
2511 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2516 WARN("Invalid argument specified\n");
2518 return D3DERR_INVALIDCALL
;
2521 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
2523 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2524 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2526 TRACE("iface %p, parameter %p, matrix %p, count %u\n", This
, parameter
, matrix
, count
);
2528 if (!count
) return D3D_OK
;
2530 if (matrix
&& param
&& count
<= param
->element_count
)
2534 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2536 switch (param
->class)
2538 case D3DXPC_MATRIX_ROWS
:
2539 for (i
= 0; i
< count
; ++i
)
2543 get_matrix(get_parameter_struct(param
->member_handles
[i
]), &m
);
2544 D3DXMatrixTranspose(&matrix
[i
], &m
);
2555 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2560 WARN("Invalid argument specified\n");
2562 return D3DERR_INVALIDCALL
;
2565 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
**matrix
, UINT count
)
2567 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2569 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This
, parameter
, matrix
, count
);
2574 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
2576 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2578 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This
, parameter
, matrix
, count
);
2583 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPCSTR string
)
2585 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2587 FIXME("iface %p, parameter %p, string %p stub\n", This
, parameter
, string
);
2592 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPCSTR
*string
)
2594 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2595 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2597 TRACE("iface %p, parameter %p, string %p\n", This
, parameter
, string
);
2599 if (string
&& param
&& !param
->element_count
&& param
->type
== D3DXPT_STRING
)
2601 *string
= *(LPCSTR
*)param
->data
;
2602 TRACE("Returning %s\n", debugstr_a(*string
));
2606 WARN("Invalid argument specified\n");
2608 return D3DERR_INVALIDCALL
;
2611 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPDIRECT3DBASETEXTURE9 texture
)
2613 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2614 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2616 TRACE("iface %p, parameter %p, texture %p\n", This
, parameter
, texture
);
2618 if (param
&& !param
->element_count
&&
2619 (param
->type
== D3DXPT_TEXTURE
|| param
->type
== D3DXPT_TEXTURE1D
2620 || param
->type
== D3DXPT_TEXTURE2D
|| param
->type
== D3DXPT_TEXTURE3D
2621 || param
->type
== D3DXPT_TEXTURECUBE
))
2623 LPDIRECT3DBASETEXTURE9 oltexture
= *(LPDIRECT3DBASETEXTURE9
*)param
->data
;
2625 if (texture
) IDirect3DBaseTexture9_AddRef(texture
);
2626 if (oltexture
) IDirect3DBaseTexture9_Release(oltexture
);
2628 *(LPDIRECT3DBASETEXTURE9
*)param
->data
= texture
;
2633 WARN("Invalid argument specified\n");
2635 return D3DERR_INVALIDCALL
;
2638 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPDIRECT3DBASETEXTURE9
*texture
)
2640 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2641 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2643 TRACE("iface %p, parameter %p, texture %p\n", This
, parameter
, texture
);
2645 if (texture
&& param
&& !param
->element_count
&&
2646 (param
->type
== D3DXPT_TEXTURE
|| param
->type
== D3DXPT_TEXTURE1D
2647 || param
->type
== D3DXPT_TEXTURE2D
|| param
->type
== D3DXPT_TEXTURE3D
2648 || param
->type
== D3DXPT_TEXTURECUBE
))
2650 *texture
= *(LPDIRECT3DBASETEXTURE9
*)param
->data
;
2651 if (*texture
) IDirect3DBaseTexture9_AddRef(*texture
);
2652 TRACE("Returning %p\n", *texture
);
2656 WARN("Invalid argument specified\n");
2658 return D3DERR_INVALIDCALL
;
2661 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPDIRECT3DPIXELSHADER9
*pshader
)
2663 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2664 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2666 TRACE("iface %p, parameter %p, pshader %p\n", This
, parameter
, pshader
);
2668 if (pshader
&& param
&& !param
->element_count
&& param
->type
== D3DXPT_PIXELSHADER
)
2670 *pshader
= *(LPDIRECT3DPIXELSHADER9
*)param
->data
;
2671 if (*pshader
) IDirect3DPixelShader9_AddRef(*pshader
);
2672 TRACE("Returning %p\n", *pshader
);
2676 WARN("Invalid argument specified\n");
2678 return D3DERR_INVALIDCALL
;
2681 static HRESULT WINAPI
ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, LPDIRECT3DVERTEXSHADER9
*vshader
)
2683 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2684 struct d3dx_parameter
*param
= get_valid_parameter(This
, parameter
);
2686 TRACE("iface %p, parameter %p, vshader %p\n", This
, parameter
, vshader
);
2688 if (vshader
&& param
&& !param
->element_count
&& param
->type
== D3DXPT_VERTEXSHADER
)
2690 *vshader
= *(LPDIRECT3DVERTEXSHADER9
*)param
->data
;
2691 if (*vshader
) IDirect3DVertexShader9_AddRef(*vshader
);
2692 TRACE("Returning %p\n", *vshader
);
2696 WARN("Invalid argument specified\n");
2698 return D3DERR_INVALIDCALL
;
2701 static HRESULT WINAPI
ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect
*iface
, D3DXHANDLE parameter
, UINT start
, UINT end
)
2703 struct ID3DXBaseEffectImpl
*This
= impl_from_ID3DXBaseEffect(iface
);
2705 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This
, parameter
, start
, end
);
2710 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl
=
2712 /*** IUnknown methods ***/
2713 ID3DXBaseEffectImpl_QueryInterface
,
2714 ID3DXBaseEffectImpl_AddRef
,
2715 ID3DXBaseEffectImpl_Release
,
2716 /*** ID3DXBaseEffect methods ***/
2717 ID3DXBaseEffectImpl_GetDesc
,
2718 ID3DXBaseEffectImpl_GetParameterDesc
,
2719 ID3DXBaseEffectImpl_GetTechniqueDesc
,
2720 ID3DXBaseEffectImpl_GetPassDesc
,
2721 ID3DXBaseEffectImpl_GetFunctionDesc
,
2722 ID3DXBaseEffectImpl_GetParameter
,
2723 ID3DXBaseEffectImpl_GetParameterByName
,
2724 ID3DXBaseEffectImpl_GetParameterBySemantic
,
2725 ID3DXBaseEffectImpl_GetParameterElement
,
2726 ID3DXBaseEffectImpl_GetTechnique
,
2727 ID3DXBaseEffectImpl_GetTechniqueByName
,
2728 ID3DXBaseEffectImpl_GetPass
,
2729 ID3DXBaseEffectImpl_GetPassByName
,
2730 ID3DXBaseEffectImpl_GetFunction
,
2731 ID3DXBaseEffectImpl_GetFunctionByName
,
2732 ID3DXBaseEffectImpl_GetAnnotation
,
2733 ID3DXBaseEffectImpl_GetAnnotationByName
,
2734 ID3DXBaseEffectImpl_SetValue
,
2735 ID3DXBaseEffectImpl_GetValue
,
2736 ID3DXBaseEffectImpl_SetBool
,
2737 ID3DXBaseEffectImpl_GetBool
,
2738 ID3DXBaseEffectImpl_SetBoolArray
,
2739 ID3DXBaseEffectImpl_GetBoolArray
,
2740 ID3DXBaseEffectImpl_SetInt
,
2741 ID3DXBaseEffectImpl_GetInt
,
2742 ID3DXBaseEffectImpl_SetIntArray
,
2743 ID3DXBaseEffectImpl_GetIntArray
,
2744 ID3DXBaseEffectImpl_SetFloat
,
2745 ID3DXBaseEffectImpl_GetFloat
,
2746 ID3DXBaseEffectImpl_SetFloatArray
,
2747 ID3DXBaseEffectImpl_GetFloatArray
,
2748 ID3DXBaseEffectImpl_SetVector
,
2749 ID3DXBaseEffectImpl_GetVector
,
2750 ID3DXBaseEffectImpl_SetVectorArray
,
2751 ID3DXBaseEffectImpl_GetVectorArray
,
2752 ID3DXBaseEffectImpl_SetMatrix
,
2753 ID3DXBaseEffectImpl_GetMatrix
,
2754 ID3DXBaseEffectImpl_SetMatrixArray
,
2755 ID3DXBaseEffectImpl_GetMatrixArray
,
2756 ID3DXBaseEffectImpl_SetMatrixPointerArray
,
2757 ID3DXBaseEffectImpl_GetMatrixPointerArray
,
2758 ID3DXBaseEffectImpl_SetMatrixTranspose
,
2759 ID3DXBaseEffectImpl_GetMatrixTranspose
,
2760 ID3DXBaseEffectImpl_SetMatrixTransposeArray
,
2761 ID3DXBaseEffectImpl_GetMatrixTransposeArray
,
2762 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray
,
2763 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray
,
2764 ID3DXBaseEffectImpl_SetString
,
2765 ID3DXBaseEffectImpl_GetString
,
2766 ID3DXBaseEffectImpl_SetTexture
,
2767 ID3DXBaseEffectImpl_GetTexture
,
2768 ID3DXBaseEffectImpl_GetPixelShader
,
2769 ID3DXBaseEffectImpl_GetVertexShader
,
2770 ID3DXBaseEffectImpl_SetArrayRange
,
2773 static inline struct ID3DXEffectImpl
*impl_from_ID3DXEffect(ID3DXEffect
*iface
)
2775 return CONTAINING_RECORD(iface
, struct ID3DXEffectImpl
, ID3DXEffect_iface
);
2778 /*** IUnknown methods ***/
2779 static HRESULT WINAPI
ID3DXEffectImpl_QueryInterface(ID3DXEffect
*iface
, REFIID riid
, void **object
)
2781 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2783 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), object
);
2785 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
2786 IsEqualGUID(riid
, &IID_ID3DXEffect
))
2788 This
->ID3DXEffect_iface
.lpVtbl
->AddRef(iface
);
2793 ERR("Interface %s not found\n", debugstr_guid(riid
));
2795 return E_NOINTERFACE
;
2798 static ULONG WINAPI
ID3DXEffectImpl_AddRef(ID3DXEffect
*iface
)
2800 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2802 TRACE("(%p)->(): AddRef from %u\n", This
, This
->ref
);
2804 return InterlockedIncrement(&This
->ref
);
2807 static ULONG WINAPI
ID3DXEffectImpl_Release(ID3DXEffect
*iface
)
2809 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2810 ULONG ref
= InterlockedDecrement(&This
->ref
);
2812 TRACE("(%p)->(): Release from %u\n", This
, ref
+ 1);
2817 HeapFree(GetProcessHeap(), 0, This
);
2823 /*** ID3DXBaseEffect methods ***/
2824 static HRESULT WINAPI
ID3DXEffectImpl_GetDesc(ID3DXEffect
*iface
, D3DXEFFECT_DESC
*desc
)
2826 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2827 ID3DXBaseEffect
*base
= This
->base_effect
;
2829 TRACE("Forward iface %p, base %p\n", This
, base
);
2831 return ID3DXBaseEffectImpl_GetDesc(base
, desc
);
2834 static HRESULT WINAPI
ID3DXEffectImpl_GetParameterDesc(ID3DXEffect
*iface
, D3DXHANDLE parameter
, D3DXPARAMETER_DESC
*desc
)
2836 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2837 ID3DXBaseEffect
*base
= This
->base_effect
;
2839 TRACE("Forward iface %p, base %p\n", This
, base
);
2841 return ID3DXBaseEffectImpl_GetParameterDesc(base
, parameter
, desc
);
2844 static HRESULT WINAPI
ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect
*iface
, D3DXHANDLE technique
, D3DXTECHNIQUE_DESC
*desc
)
2846 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2847 ID3DXBaseEffect
*base
= This
->base_effect
;
2849 TRACE("Forward iface %p, base %p\n", This
, base
);
2851 return ID3DXBaseEffectImpl_GetTechniqueDesc(base
, technique
, desc
);
2854 static HRESULT WINAPI
ID3DXEffectImpl_GetPassDesc(ID3DXEffect
*iface
, D3DXHANDLE pass
, D3DXPASS_DESC
*desc
)
2856 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2857 ID3DXBaseEffect
*base
= This
->base_effect
;
2859 TRACE("Forward iface %p, base %p\n", This
, base
);
2861 return ID3DXBaseEffectImpl_GetPassDesc(base
, pass
, desc
);
2864 static HRESULT WINAPI
ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect
*iface
, D3DXHANDLE shader
, D3DXFUNCTION_DESC
*desc
)
2866 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2867 ID3DXBaseEffect
*base
= This
->base_effect
;
2869 TRACE("Forward iface %p, base %p\n", This
, base
);
2871 return ID3DXBaseEffectImpl_GetFunctionDesc(base
, shader
, desc
);
2874 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameter(ID3DXEffect
*iface
, D3DXHANDLE parameter
, UINT index
)
2876 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2877 ID3DXBaseEffect
*base
= This
->base_effect
;
2879 TRACE("Forward iface %p, base %p\n", This
, base
);
2881 return ID3DXBaseEffectImpl_GetParameter(base
, parameter
, index
);
2884 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameterByName(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPCSTR name
)
2886 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2887 ID3DXBaseEffect
*base
= This
->base_effect
;
2889 TRACE("Forward iface %p, base %p\n", This
, base
);
2891 return ID3DXBaseEffectImpl_GetParameterByName(base
, parameter
, name
);
2894 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPCSTR semantic
)
2896 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2897 ID3DXBaseEffect
*base
= This
->base_effect
;
2899 TRACE("Forward iface %p, base %p\n", This
, base
);
2901 return ID3DXBaseEffectImpl_GetParameterBySemantic(base
, parameter
, semantic
);
2904 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameterElement(ID3DXEffect
*iface
, D3DXHANDLE parameter
, UINT index
)
2906 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2907 ID3DXBaseEffect
*base
= This
->base_effect
;
2909 TRACE("Forward iface %p, base %p\n", This
, base
);
2911 return ID3DXBaseEffectImpl_GetParameterElement(base
, parameter
, index
);
2914 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetTechnique(ID3DXEffect
*iface
, UINT index
)
2916 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2917 ID3DXBaseEffect
*base
= This
->base_effect
;
2919 TRACE("Forward iface %p, base %p\n", This
, base
);
2921 return ID3DXBaseEffectImpl_GetTechnique(base
, index
);
2924 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect
*iface
, LPCSTR name
)
2926 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2927 ID3DXBaseEffect
*base
= This
->base_effect
;
2929 TRACE("Forward iface %p, base %p\n", This
, base
);
2931 return ID3DXBaseEffectImpl_GetTechniqueByName(base
, name
);
2934 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetPass(ID3DXEffect
*iface
, D3DXHANDLE technique
, UINT index
)
2936 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2937 ID3DXBaseEffect
*base
= This
->base_effect
;
2939 TRACE("Forward iface %p, base %p\n", This
, base
);
2941 return ID3DXBaseEffectImpl_GetPass(base
, technique
, index
);
2944 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetPassByName(ID3DXEffect
*iface
, D3DXHANDLE technique
, LPCSTR name
)
2946 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2947 ID3DXBaseEffect
*base
= This
->base_effect
;
2949 TRACE("Forward iface %p, base %p\n", This
, base
);
2951 return ID3DXBaseEffectImpl_GetPassByName(base
, technique
, name
);
2954 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetFunction(ID3DXEffect
*iface
, UINT index
)
2956 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2957 ID3DXBaseEffect
*base
= This
->base_effect
;
2959 TRACE("Forward iface %p, base %p\n", This
, base
);
2961 return ID3DXBaseEffectImpl_GetFunction(base
, index
);
2964 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetFunctionByName(ID3DXEffect
*iface
, LPCSTR name
)
2966 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2967 ID3DXBaseEffect
*base
= This
->base_effect
;
2969 TRACE("Forward iface %p, base %p\n", This
, base
);
2971 return ID3DXBaseEffectImpl_GetFunctionByName(base
, name
);
2974 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetAnnotation(ID3DXEffect
*iface
, D3DXHANDLE object
, UINT index
)
2976 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2977 ID3DXBaseEffect
*base
= This
->base_effect
;
2979 TRACE("Forward iface %p, base %p\n", This
, base
);
2981 return ID3DXBaseEffectImpl_GetAnnotation(base
, object
, index
);
2984 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect
*iface
, D3DXHANDLE object
, LPCSTR name
)
2986 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2987 ID3DXBaseEffect
*base
= This
->base_effect
;
2989 TRACE("Forward iface %p, base %p\n", This
, base
);
2991 return ID3DXBaseEffectImpl_GetAnnotationByName(base
, object
, name
);
2994 static HRESULT WINAPI
ID3DXEffectImpl_SetValue(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPCVOID data
, UINT bytes
)
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_SetValue(base
, parameter
, data
, bytes
);
3004 static HRESULT WINAPI
ID3DXEffectImpl_GetValue(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPVOID data
, UINT bytes
)
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_GetValue(base
, parameter
, data
, bytes
);
3014 static HRESULT WINAPI
ID3DXEffectImpl_SetBool(ID3DXEffect
*iface
, D3DXHANDLE parameter
, BOOL b
)
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_SetBool(base
, parameter
, b
);
3024 static HRESULT WINAPI
ID3DXEffectImpl_GetBool(ID3DXEffect
*iface
, D3DXHANDLE parameter
, BOOL
*b
)
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_GetBool(base
, parameter
, b
);
3034 static HRESULT WINAPI
ID3DXEffectImpl_SetBoolArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST BOOL
*b
, UINT count
)
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_SetBoolArray(base
, parameter
, b
, count
);
3044 static HRESULT WINAPI
ID3DXEffectImpl_GetBoolArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, BOOL
*b
, UINT count
)
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_GetBoolArray(base
, parameter
, b
, count
);
3054 static HRESULT WINAPI
ID3DXEffectImpl_SetInt(ID3DXEffect
*iface
, D3DXHANDLE parameter
, INT n
)
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_SetInt(base
, parameter
, n
);
3064 static HRESULT WINAPI
ID3DXEffectImpl_GetInt(ID3DXEffect
*iface
, D3DXHANDLE parameter
, INT
*n
)
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_GetInt(base
, parameter
, n
);
3074 static HRESULT WINAPI
ID3DXEffectImpl_SetIntArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST INT
*n
, UINT count
)
3076 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3077 ID3DXBaseEffect
*base
= This
->base_effect
;
3079 TRACE("Forward iface %p, base %p\n", This
, base
);
3081 return ID3DXBaseEffectImpl_SetIntArray(base
, parameter
, n
, count
);
3084 static HRESULT WINAPI
ID3DXEffectImpl_GetIntArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, INT
*n
, UINT count
)
3086 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3087 ID3DXBaseEffect
*base
= This
->base_effect
;
3089 TRACE("Forward iface %p, base %p\n", This
, base
);
3091 return ID3DXBaseEffectImpl_GetIntArray(base
, parameter
, n
, count
);
3094 static HRESULT WINAPI
ID3DXEffectImpl_SetFloat(ID3DXEffect
*iface
, D3DXHANDLE parameter
, FLOAT f
)
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_SetFloat(base
, parameter
, f
);
3104 static HRESULT WINAPI
ID3DXEffectImpl_GetFloat(ID3DXEffect
*iface
, D3DXHANDLE parameter
, FLOAT
*f
)
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_GetFloat(base
, parameter
, f
);
3114 static HRESULT WINAPI
ID3DXEffectImpl_SetFloatArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST FLOAT
*f
, UINT count
)
3116 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3117 ID3DXBaseEffect
*base
= This
->base_effect
;
3119 TRACE("Forward iface %p, base %p\n", This
, base
);
3121 return ID3DXBaseEffectImpl_SetFloatArray(base
, parameter
, f
, count
);
3124 static HRESULT WINAPI
ID3DXEffectImpl_GetFloatArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, FLOAT
*f
, UINT count
)
3126 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3127 ID3DXBaseEffect
*base
= This
->base_effect
;
3129 TRACE("Forward iface %p, base %p\n", This
, base
);
3131 return ID3DXBaseEffectImpl_GetFloatArray(base
, parameter
, f
, count
);
3134 static HRESULT WINAPI
ID3DXEffectImpl_SetVector(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXVECTOR4
*vector
)
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_SetVector(base
, parameter
, vector
);
3144 static HRESULT WINAPI
ID3DXEffectImpl_GetVector(ID3DXEffect
*iface
, D3DXHANDLE parameter
, D3DXVECTOR4
*vector
)
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_GetVector(base
, parameter
, vector
);
3154 static HRESULT WINAPI
ID3DXEffectImpl_SetVectorArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXVECTOR4
*vector
, UINT count
)
3156 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3157 ID3DXBaseEffect
*base
= This
->base_effect
;
3159 TRACE("Forward iface %p, base %p\n", This
, base
);
3161 return ID3DXBaseEffectImpl_SetVectorArray(base
, parameter
, vector
, count
);
3164 static HRESULT WINAPI
ID3DXEffectImpl_GetVectorArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, D3DXVECTOR4
*vector
, 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_GetVectorArray(base
, parameter
, vector
, count
);
3174 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrix(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
)
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_SetMatrix(base
, parameter
, matrix
);
3184 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrix(ID3DXEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
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_GetMatrix(base
, parameter
, matrix
);
3194 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
, UINT count
)
3196 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3197 ID3DXBaseEffect
*base
= This
->base_effect
;
3199 TRACE("Forward iface %p, base %p\n", This
, base
);
3201 return ID3DXBaseEffectImpl_SetMatrixArray(base
, parameter
, matrix
, count
);
3204 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, 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_GetMatrixArray(base
, parameter
, matrix
, count
);
3214 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
**matrix
, 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_SetMatrixPointerArray(base
, parameter
, matrix
, count
);
3224 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
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_GetMatrixPointerArray(base
, parameter
, matrix
, count
);
3234 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
)
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_SetMatrixTranspose(base
, parameter
, matrix
);
3244 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
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_GetMatrixTranspose(base
, parameter
, matrix
);
3254 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
, UINT count
)
3256 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3257 ID3DXBaseEffect
*base
= This
->base_effect
;
3259 TRACE("Forward iface %p, base %p\n", This
, base
);
3261 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base
, parameter
, matrix
, count
);
3264 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
3266 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3267 ID3DXBaseEffect
*base
= This
->base_effect
;
3269 TRACE("Forward iface %p, base %p\n", This
, base
);
3271 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base
, parameter
, matrix
, count
);
3274 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
**matrix
, UINT count
)
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_SetMatrixTransposePointerArray(base
, parameter
, matrix
, count
);
3284 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, 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_GetMatrixTransposePointerArray(base
, parameter
, matrix
, count
);
3294 static HRESULT WINAPI
ID3DXEffectImpl_SetString(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPCSTR string
)
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_SetString(base
, parameter
, string
);
3304 static HRESULT WINAPI
ID3DXEffectImpl_GetString(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPCSTR
*string
)
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_GetString(base
, parameter
, string
);
3314 static HRESULT WINAPI
ID3DXEffectImpl_SetTexture(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPDIRECT3DBASETEXTURE9 texture
)
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_SetTexture(base
, parameter
, texture
);
3324 static HRESULT WINAPI
ID3DXEffectImpl_GetTexture(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPDIRECT3DBASETEXTURE9
*texture
)
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_GetTexture(base
, parameter
, texture
);
3334 static HRESULT WINAPI
ID3DXEffectImpl_GetPixelShader(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPDIRECT3DPIXELSHADER9
*pshader
)
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_GetPixelShader(base
, parameter
, pshader
);
3344 static HRESULT WINAPI
ID3DXEffectImpl_GetVertexShader(ID3DXEffect
*iface
, D3DXHANDLE parameter
, LPDIRECT3DVERTEXSHADER9
*vshader
)
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_GetVertexShader(base
, parameter
, vshader
);
3354 static HRESULT WINAPI
ID3DXEffectImpl_SetArrayRange(ID3DXEffect
*iface
, D3DXHANDLE parameter
, UINT start
, UINT end
)
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_SetArrayRange(base
, parameter
, start
, end
);
3364 /*** ID3DXEffect methods ***/
3365 static HRESULT WINAPI
ID3DXEffectImpl_GetPool(ID3DXEffect
*iface
, LPD3DXEFFECTPOOL
*pool
)
3367 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3369 TRACE("iface %p, pool %p\n", This
, pool
);
3373 WARN("Invalid argument supplied.\n");
3374 return D3DERR_INVALIDCALL
;
3379 This
->pool
->lpVtbl
->AddRef(This
->pool
);
3384 TRACE("Returning pool %p\n", *pool
);
3389 static HRESULT WINAPI
ID3DXEffectImpl_SetTechnique(ID3DXEffect
*iface
, D3DXHANDLE technique
)
3391 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3392 struct ID3DXBaseEffectImpl
*base
= impl_from_ID3DXBaseEffect(This
->base_effect
);
3393 struct d3dx_technique
*tech
= is_valid_technique(base
, technique
);
3395 TRACE("iface %p, technique %p\n", This
, technique
);
3397 if (!tech
) tech
= get_technique_struct(iface
->lpVtbl
->GetTechniqueByName(iface
, technique
));
3403 for (i
= 0; i
< base
->technique_count
; ++i
)
3405 struct d3dx_technique
*t
= get_technique_struct(base
->technique_handles
[i
]);
3409 This
->active_technique
= get_technique_handle(t
);
3410 TRACE("Technique %u (%p)\n", i
, tech
);
3416 WARN("Invalid argument supplied.\n");
3418 return D3DERR_INVALIDCALL
;
3421 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect
*iface
)
3423 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3425 TRACE("iface %p\n", This
);
3427 return This
->active_technique
;
3430 static HRESULT WINAPI
ID3DXEffectImpl_ValidateTechnique(ID3DXEffect
* iface
, D3DXHANDLE technique
)
3432 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3434 FIXME("(%p)->(%p): stub\n", This
, technique
);
3439 static HRESULT WINAPI
ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect
* iface
, D3DXHANDLE technique
, D3DXHANDLE
* next_technique
)
3441 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3443 FIXME("(%p)->(%p, %p): stub\n", This
, technique
, next_technique
);
3448 static BOOL WINAPI
ID3DXEffectImpl_IsParameterUsed(ID3DXEffect
* iface
, D3DXHANDLE parameter
, D3DXHANDLE technique
)
3450 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3452 FIXME("(%p)->(%p, %p): stub\n", This
, parameter
, technique
);
3457 static HRESULT WINAPI
ID3DXEffectImpl_Begin(ID3DXEffect
*iface
, UINT
*passes
, DWORD flags
)
3459 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3460 struct d3dx_technique
*technique
= get_technique_struct(This
->active_technique
);
3462 FIXME("iface %p, passes %p, flags %#x partial stub\n", This
, passes
, flags
);
3464 if (passes
&& technique
)
3466 if (This
->manager
|| flags
& D3DXFX_DONOTSAVESTATE
)
3468 TRACE("State capturing disabled.\n");
3472 FIXME("State capturing not supported, yet!\n");
3475 *passes
= technique
->pass_count
;
3480 WARN("Invalid argument supplied.\n");
3482 return D3DERR_INVALIDCALL
;
3485 static HRESULT WINAPI
ID3DXEffectImpl_BeginPass(ID3DXEffect
*iface
, UINT pass
)
3487 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3488 struct d3dx_technique
*technique
= get_technique_struct(This
->active_technique
);
3490 TRACE("iface %p, pass %u\n", This
, pass
);
3492 if (technique
&& pass
< technique
->pass_count
&& !This
->active_pass
)
3494 This
->active_pass
= technique
->pass_handles
[pass
];
3496 FIXME("No states applied, yet!\n");
3501 WARN("Invalid argument supplied.\n");
3503 return D3DERR_INVALIDCALL
;
3506 static HRESULT WINAPI
ID3DXEffectImpl_CommitChanges(ID3DXEffect
* iface
)
3508 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3510 FIXME("(%p)->(): stub\n", This
);
3515 static HRESULT WINAPI
ID3DXEffectImpl_EndPass(ID3DXEffect
*iface
)
3517 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3519 TRACE("iface %p\n", This
);
3521 if (This
->active_pass
)
3523 This
->active_pass
= NULL
;
3527 WARN("Invalid call.\n");
3529 return D3DERR_INVALIDCALL
;
3532 static HRESULT WINAPI
ID3DXEffectImpl_End(ID3DXEffect
* iface
)
3534 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3536 FIXME("(%p)->(): stub\n", This
);
3541 static HRESULT WINAPI
ID3DXEffectImpl_GetDevice(ID3DXEffect
*iface
, LPDIRECT3DDEVICE9
*device
)
3543 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3545 TRACE("iface %p, device %p\n", This
, device
);
3549 WARN("Invalid argument supplied.\n");
3550 return D3DERR_INVALIDCALL
;
3553 IDirect3DDevice9_AddRef(This
->device
);
3555 *device
= This
->device
;
3557 TRACE("Returning device %p\n", *device
);
3562 static HRESULT WINAPI
ID3DXEffectImpl_OnLostDevice(ID3DXEffect
* iface
)
3564 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3566 FIXME("(%p)->(): stub\n", This
);
3571 static HRESULT WINAPI
ID3DXEffectImpl_OnResetDevice(ID3DXEffect
* iface
)
3573 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3575 FIXME("(%p)->(): stub\n", This
);
3580 static HRESULT WINAPI
ID3DXEffectImpl_SetStateManager(ID3DXEffect
*iface
, LPD3DXEFFECTSTATEMANAGER manager
)
3582 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3584 TRACE("iface %p, manager %p\n", This
, manager
);
3586 if (manager
) IUnknown_AddRef(manager
);
3587 if (This
->manager
) IUnknown_Release(This
->manager
);
3589 This
->manager
= manager
;
3594 static HRESULT WINAPI
ID3DXEffectImpl_GetStateManager(ID3DXEffect
*iface
, LPD3DXEFFECTSTATEMANAGER
*manager
)
3596 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3598 TRACE("iface %p, manager %p\n", This
, manager
);
3602 WARN("Invalid argument supplied.\n");
3603 return D3DERR_INVALIDCALL
;
3606 if (This
->manager
) IUnknown_AddRef(This
->manager
);
3607 *manager
= This
->manager
;
3612 static HRESULT WINAPI
ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect
* iface
)
3614 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3616 FIXME("(%p)->(): stub\n", This
);
3621 static D3DXHANDLE WINAPI
ID3DXEffectImpl_EndParameterBlock(ID3DXEffect
* iface
)
3623 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3625 FIXME("(%p)->(): stub\n", This
);
3630 static HRESULT WINAPI
ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect
* iface
, D3DXHANDLE parameter_block
)
3632 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3634 FIXME("(%p)->(%p): stub\n", This
, parameter_block
);
3639 static HRESULT WINAPI
ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect
* iface
, D3DXHANDLE parameter_block
)
3641 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3643 FIXME("(%p)->(%p): stub\n", This
, parameter_block
);
3648 static HRESULT WINAPI
ID3DXEffectImpl_CloneEffect(ID3DXEffect
* iface
, LPDIRECT3DDEVICE9 device
, LPD3DXEFFECT
* effect
)
3650 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3652 FIXME("(%p)->(%p, %p): stub\n", This
, device
, effect
);
3657 static HRESULT WINAPI
ID3DXEffectImpl_SetRawValue(ID3DXEffect
* iface
, D3DXHANDLE parameter
, LPCVOID data
, UINT byte_offset
, UINT bytes
)
3659 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3661 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This
, parameter
, data
, byte_offset
, bytes
);
3666 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl
=
3668 /*** IUnknown methods ***/
3669 ID3DXEffectImpl_QueryInterface
,
3670 ID3DXEffectImpl_AddRef
,
3671 ID3DXEffectImpl_Release
,
3672 /*** ID3DXBaseEffect methods ***/
3673 ID3DXEffectImpl_GetDesc
,
3674 ID3DXEffectImpl_GetParameterDesc
,
3675 ID3DXEffectImpl_GetTechniqueDesc
,
3676 ID3DXEffectImpl_GetPassDesc
,
3677 ID3DXEffectImpl_GetFunctionDesc
,
3678 ID3DXEffectImpl_GetParameter
,
3679 ID3DXEffectImpl_GetParameterByName
,
3680 ID3DXEffectImpl_GetParameterBySemantic
,
3681 ID3DXEffectImpl_GetParameterElement
,
3682 ID3DXEffectImpl_GetTechnique
,
3683 ID3DXEffectImpl_GetTechniqueByName
,
3684 ID3DXEffectImpl_GetPass
,
3685 ID3DXEffectImpl_GetPassByName
,
3686 ID3DXEffectImpl_GetFunction
,
3687 ID3DXEffectImpl_GetFunctionByName
,
3688 ID3DXEffectImpl_GetAnnotation
,
3689 ID3DXEffectImpl_GetAnnotationByName
,
3690 ID3DXEffectImpl_SetValue
,
3691 ID3DXEffectImpl_GetValue
,
3692 ID3DXEffectImpl_SetBool
,
3693 ID3DXEffectImpl_GetBool
,
3694 ID3DXEffectImpl_SetBoolArray
,
3695 ID3DXEffectImpl_GetBoolArray
,
3696 ID3DXEffectImpl_SetInt
,
3697 ID3DXEffectImpl_GetInt
,
3698 ID3DXEffectImpl_SetIntArray
,
3699 ID3DXEffectImpl_GetIntArray
,
3700 ID3DXEffectImpl_SetFloat
,
3701 ID3DXEffectImpl_GetFloat
,
3702 ID3DXEffectImpl_SetFloatArray
,
3703 ID3DXEffectImpl_GetFloatArray
,
3704 ID3DXEffectImpl_SetVector
,
3705 ID3DXEffectImpl_GetVector
,
3706 ID3DXEffectImpl_SetVectorArray
,
3707 ID3DXEffectImpl_GetVectorArray
,
3708 ID3DXEffectImpl_SetMatrix
,
3709 ID3DXEffectImpl_GetMatrix
,
3710 ID3DXEffectImpl_SetMatrixArray
,
3711 ID3DXEffectImpl_GetMatrixArray
,
3712 ID3DXEffectImpl_SetMatrixPointerArray
,
3713 ID3DXEffectImpl_GetMatrixPointerArray
,
3714 ID3DXEffectImpl_SetMatrixTranspose
,
3715 ID3DXEffectImpl_GetMatrixTranspose
,
3716 ID3DXEffectImpl_SetMatrixTransposeArray
,
3717 ID3DXEffectImpl_GetMatrixTransposeArray
,
3718 ID3DXEffectImpl_SetMatrixTransposePointerArray
,
3719 ID3DXEffectImpl_GetMatrixTransposePointerArray
,
3720 ID3DXEffectImpl_SetString
,
3721 ID3DXEffectImpl_GetString
,
3722 ID3DXEffectImpl_SetTexture
,
3723 ID3DXEffectImpl_GetTexture
,
3724 ID3DXEffectImpl_GetPixelShader
,
3725 ID3DXEffectImpl_GetVertexShader
,
3726 ID3DXEffectImpl_SetArrayRange
,
3727 /*** ID3DXEffect methods ***/
3728 ID3DXEffectImpl_GetPool
,
3729 ID3DXEffectImpl_SetTechnique
,
3730 ID3DXEffectImpl_GetCurrentTechnique
,
3731 ID3DXEffectImpl_ValidateTechnique
,
3732 ID3DXEffectImpl_FindNextValidTechnique
,
3733 ID3DXEffectImpl_IsParameterUsed
,
3734 ID3DXEffectImpl_Begin
,
3735 ID3DXEffectImpl_BeginPass
,
3736 ID3DXEffectImpl_CommitChanges
,
3737 ID3DXEffectImpl_EndPass
,
3738 ID3DXEffectImpl_End
,
3739 ID3DXEffectImpl_GetDevice
,
3740 ID3DXEffectImpl_OnLostDevice
,
3741 ID3DXEffectImpl_OnResetDevice
,
3742 ID3DXEffectImpl_SetStateManager
,
3743 ID3DXEffectImpl_GetStateManager
,
3744 ID3DXEffectImpl_BeginParameterBlock
,
3745 ID3DXEffectImpl_EndParameterBlock
,
3746 ID3DXEffectImpl_ApplyParameterBlock
,
3747 ID3DXEffectImpl_DeleteParameterBlock
,
3748 ID3DXEffectImpl_CloneEffect
,
3749 ID3DXEffectImpl_SetRawValue
3752 static inline struct ID3DXEffectCompilerImpl
*impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler
*iface
)
3754 return CONTAINING_RECORD(iface
, struct ID3DXEffectCompilerImpl
, ID3DXEffectCompiler_iface
);
3757 /*** IUnknown methods ***/
3758 static HRESULT WINAPI
ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler
*iface
, REFIID riid
, void **object
)
3760 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), object
);
3762 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
3763 IsEqualGUID(riid
, &IID_ID3DXEffectCompiler
))
3765 iface
->lpVtbl
->AddRef(iface
);
3770 ERR("Interface %s not found\n", debugstr_guid(riid
));
3772 return E_NOINTERFACE
;
3775 static ULONG WINAPI
ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler
*iface
)
3777 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3779 TRACE("iface %p: AddRef from %u\n", iface
, This
->ref
);
3781 return InterlockedIncrement(&This
->ref
);
3784 static ULONG WINAPI
ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler
*iface
)
3786 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3787 ULONG ref
= InterlockedDecrement(&This
->ref
);
3789 TRACE("iface %p: Release from %u\n", iface
, ref
+ 1);
3793 free_effect_compiler(This
);
3794 HeapFree(GetProcessHeap(), 0, This
);
3800 /*** ID3DXBaseEffect methods ***/
3801 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler
*iface
, D3DXEFFECT_DESC
*desc
)
3803 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3804 ID3DXBaseEffect
*base
= This
->base_effect
;
3806 TRACE("Forward iface %p, base %p\n", This
, base
);
3808 return ID3DXBaseEffectImpl_GetDesc(base
, desc
);
3811 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, D3DXPARAMETER_DESC
*desc
)
3813 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3814 ID3DXBaseEffect
*base
= This
->base_effect
;
3816 TRACE("Forward iface %p, base %p\n", This
, base
);
3818 return ID3DXBaseEffectImpl_GetParameterDesc(base
, parameter
, desc
);
3821 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler
*iface
, D3DXHANDLE technique
, D3DXTECHNIQUE_DESC
*desc
)
3823 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3824 ID3DXBaseEffect
*base
= This
->base_effect
;
3826 TRACE("Forward iface %p, base %p\n", This
, base
);
3828 return ID3DXBaseEffectImpl_GetTechniqueDesc(base
, technique
, desc
);
3831 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler
*iface
, D3DXHANDLE pass
, D3DXPASS_DESC
*desc
)
3833 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3834 ID3DXBaseEffect
*base
= This
->base_effect
;
3836 TRACE("Forward iface %p, base %p\n", This
, base
);
3838 return ID3DXBaseEffectImpl_GetPassDesc(base
, pass
, desc
);
3841 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler
*iface
, D3DXHANDLE shader
, D3DXFUNCTION_DESC
*desc
)
3843 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3844 ID3DXBaseEffect
*base
= This
->base_effect
;
3846 TRACE("Forward iface %p, base %p\n", This
, base
);
3848 return ID3DXBaseEffectImpl_GetFunctionDesc(base
, shader
, desc
);
3851 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, UINT index
)
3853 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3854 ID3DXBaseEffect
*base
= This
->base_effect
;
3856 TRACE("Forward iface %p, base %p\n", This
, base
);
3858 return ID3DXBaseEffectImpl_GetParameter(base
, parameter
, index
);
3861 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPCSTR name
)
3863 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3864 ID3DXBaseEffect
*base
= This
->base_effect
;
3866 TRACE("Forward iface %p, base %p\n", This
, base
);
3868 return ID3DXBaseEffectImpl_GetParameterByName(base
, parameter
, name
);
3871 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPCSTR semantic
)
3873 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3874 ID3DXBaseEffect
*base
= This
->base_effect
;
3876 TRACE("Forward iface %p, base %p\n", This
, base
);
3878 return ID3DXBaseEffectImpl_GetParameterBySemantic(base
, parameter
, semantic
);
3881 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, UINT index
)
3883 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3884 ID3DXBaseEffect
*base
= This
->base_effect
;
3886 TRACE("Forward iface %p, base %p\n", This
, base
);
3888 return ID3DXBaseEffectImpl_GetParameterElement(base
, parameter
, index
);
3891 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler
*iface
, UINT index
)
3893 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3894 ID3DXBaseEffect
*base
= This
->base_effect
;
3896 TRACE("Forward iface %p, base %p\n", This
, base
);
3898 return ID3DXBaseEffectImpl_GetTechnique(base
, index
);
3901 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler
*iface
, LPCSTR name
)
3903 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3904 ID3DXBaseEffect
*base
= This
->base_effect
;
3906 TRACE("Forward iface %p, base %p\n", This
, base
);
3908 return ID3DXBaseEffectImpl_GetTechniqueByName(base
, name
);
3911 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler
*iface
, D3DXHANDLE technique
, UINT index
)
3913 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3914 ID3DXBaseEffect
*base
= This
->base_effect
;
3916 TRACE("Forward iface %p, base %p\n", This
, base
);
3918 return ID3DXBaseEffectImpl_GetPass(base
, technique
, index
);
3921 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler
*iface
, D3DXHANDLE technique
, LPCSTR name
)
3923 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3924 ID3DXBaseEffect
*base
= This
->base_effect
;
3926 TRACE("Forward iface %p, base %p\n", This
, base
);
3928 return ID3DXBaseEffectImpl_GetPassByName(base
, technique
, name
);
3931 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler
*iface
, UINT index
)
3933 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3934 ID3DXBaseEffect
*base
= This
->base_effect
;
3936 TRACE("Forward iface %p, base %p\n", This
, base
);
3938 return ID3DXBaseEffectImpl_GetFunction(base
, index
);
3941 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler
*iface
, LPCSTR name
)
3943 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3944 ID3DXBaseEffect
*base
= This
->base_effect
;
3946 TRACE("Forward iface %p, base %p\n", This
, base
);
3948 return ID3DXBaseEffectImpl_GetFunctionByName(base
, name
);
3951 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler
*iface
, D3DXHANDLE object
, UINT index
)
3953 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3954 ID3DXBaseEffect
*base
= This
->base_effect
;
3956 TRACE("Forward iface %p, base %p\n", This
, base
);
3958 return ID3DXBaseEffectImpl_GetAnnotation(base
, object
, index
);
3961 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler
*iface
, D3DXHANDLE object
, LPCSTR name
)
3963 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3964 ID3DXBaseEffect
*base
= This
->base_effect
;
3966 TRACE("Forward iface %p, base %p\n", This
, base
);
3968 return ID3DXBaseEffectImpl_GetAnnotationByName(base
, object
, name
);
3971 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPCVOID data
, UINT bytes
)
3973 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3974 ID3DXBaseEffect
*base
= This
->base_effect
;
3976 TRACE("Forward iface %p, base %p\n", This
, base
);
3978 return ID3DXBaseEffectImpl_SetValue(base
, parameter
, data
, bytes
);
3981 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPVOID data
, UINT bytes
)
3983 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3984 ID3DXBaseEffect
*base
= This
->base_effect
;
3986 TRACE("Forward iface %p, base %p\n", This
, base
);
3988 return ID3DXBaseEffectImpl_GetValue(base
, parameter
, data
, bytes
);
3991 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL b
)
3993 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3994 ID3DXBaseEffect
*base
= This
->base_effect
;
3996 TRACE("Forward iface %p, base %p\n", This
, base
);
3998 return ID3DXBaseEffectImpl_SetBool(base
, parameter
, b
);
4001 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL
*b
)
4003 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4004 ID3DXBaseEffect
*base
= This
->base_effect
;
4006 TRACE("Forward iface %p, base %p\n", This
, base
);
4008 return ID3DXBaseEffectImpl_GetBool(base
, parameter
, b
);
4011 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST BOOL
*b
, UINT count
)
4013 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4014 ID3DXBaseEffect
*base
= This
->base_effect
;
4016 TRACE("Forward iface %p, base %p\n", This
, base
);
4018 return ID3DXBaseEffectImpl_SetBoolArray(base
, parameter
, b
, count
);
4021 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL
*b
, UINT count
)
4023 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4024 ID3DXBaseEffect
*base
= This
->base_effect
;
4026 TRACE("Forward iface %p, base %p\n", This
, base
);
4028 return ID3DXBaseEffectImpl_GetBoolArray(base
, parameter
, b
, count
);
4031 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, INT n
)
4033 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4034 ID3DXBaseEffect
*base
= This
->base_effect
;
4036 TRACE("Forward iface %p, base %p\n", This
, base
);
4038 return ID3DXBaseEffectImpl_SetInt(base
, parameter
, n
);
4041 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, INT
*n
)
4043 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4044 ID3DXBaseEffect
*base
= This
->base_effect
;
4046 TRACE("Forward iface %p, base %p\n", This
, base
);
4048 return ID3DXBaseEffectImpl_GetInt(base
, parameter
, n
);
4051 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST INT
*n
, UINT count
)
4053 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4054 ID3DXBaseEffect
*base
= This
->base_effect
;
4056 TRACE("Forward iface %p, base %p\n", This
, base
);
4058 return ID3DXBaseEffectImpl_SetIntArray(base
, parameter
, n
, count
);
4061 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, INT
*n
, UINT count
)
4063 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4064 ID3DXBaseEffect
*base
= This
->base_effect
;
4066 TRACE("Forward iface %p, base %p\n", This
, base
);
4068 return ID3DXBaseEffectImpl_GetIntArray(base
, parameter
, n
, count
);
4071 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, FLOAT f
)
4073 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4074 ID3DXBaseEffect
*base
= This
->base_effect
;
4076 TRACE("Forward iface %p, base %p\n", This
, base
);
4078 return ID3DXBaseEffectImpl_SetFloat(base
, parameter
, f
);
4081 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, FLOAT
*f
)
4083 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4084 ID3DXBaseEffect
*base
= This
->base_effect
;
4086 TRACE("Forward iface %p, base %p\n", This
, base
);
4088 return ID3DXBaseEffectImpl_GetFloat(base
, parameter
, f
);
4091 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST FLOAT
*f
, UINT count
)
4093 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4094 ID3DXBaseEffect
*base
= This
->base_effect
;
4096 TRACE("Forward iface %p, base %p\n", This
, base
);
4098 return ID3DXBaseEffectImpl_SetFloatArray(base
, parameter
, f
, count
);
4101 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, FLOAT
*f
, UINT count
)
4103 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4104 ID3DXBaseEffect
*base
= This
->base_effect
;
4106 TRACE("Forward iface %p, base %p\n", This
, base
);
4108 return ID3DXBaseEffectImpl_GetFloatArray(base
, parameter
, f
, count
);
4111 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST D3DXVECTOR4
*vector
)
4113 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4114 ID3DXBaseEffect
*base
= This
->base_effect
;
4116 TRACE("Forward iface %p, base %p\n", This
, base
);
4118 return ID3DXBaseEffectImpl_SetVector(base
, parameter
, vector
);
4121 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, D3DXVECTOR4
*vector
)
4123 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4124 ID3DXBaseEffect
*base
= This
->base_effect
;
4126 TRACE("Forward iface %p, base %p\n", This
, base
);
4128 return ID3DXBaseEffectImpl_GetVector(base
, parameter
, vector
);
4131 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST D3DXVECTOR4
*vector
, UINT count
)
4133 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4134 ID3DXBaseEffect
*base
= This
->base_effect
;
4136 TRACE("Forward iface %p, base %p\n", This
, base
);
4138 return ID3DXBaseEffectImpl_SetVectorArray(base
, parameter
, vector
, count
);
4141 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, D3DXVECTOR4
*vector
, UINT count
)
4143 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4144 ID3DXBaseEffect
*base
= This
->base_effect
;
4146 TRACE("Forward iface %p, base %p\n", This
, base
);
4148 return ID3DXBaseEffectImpl_GetVectorArray(base
, parameter
, vector
, count
);
4151 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
)
4153 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4154 ID3DXBaseEffect
*base
= This
->base_effect
;
4156 TRACE("Forward iface %p, base %p\n", This
, base
);
4158 return ID3DXBaseEffectImpl_SetMatrix(base
, parameter
, matrix
);
4161 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
4163 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4164 ID3DXBaseEffect
*base
= This
->base_effect
;
4166 TRACE("Forward iface %p, base %p\n", This
, base
);
4168 return ID3DXBaseEffectImpl_GetMatrix(base
, parameter
, matrix
);
4171 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
, UINT count
)
4173 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4174 ID3DXBaseEffect
*base
= This
->base_effect
;
4176 TRACE("Forward iface %p, base %p\n", This
, base
);
4178 return ID3DXBaseEffectImpl_SetMatrixArray(base
, parameter
, matrix
, count
);
4181 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
4183 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4184 ID3DXBaseEffect
*base
= This
->base_effect
;
4186 TRACE("Forward iface %p, base %p\n", This
, base
);
4188 return ID3DXBaseEffectImpl_GetMatrixArray(base
, parameter
, matrix
, count
);
4191 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
**matrix
, UINT count
)
4193 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4194 ID3DXBaseEffect
*base
= This
->base_effect
;
4196 TRACE("Forward iface %p, base %p\n", This
, base
);
4198 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base
, parameter
, matrix
, count
);
4201 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
4203 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4204 ID3DXBaseEffect
*base
= This
->base_effect
;
4206 TRACE("Forward iface %p, base %p\n", This
, base
);
4208 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base
, parameter
, matrix
, count
);
4211 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
)
4213 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4214 ID3DXBaseEffect
*base
= This
->base_effect
;
4216 TRACE("Forward iface %p, base %p\n", This
, base
);
4218 return ID3DXBaseEffectImpl_SetMatrixTranspose(base
, parameter
, matrix
);
4221 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
4223 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4224 ID3DXBaseEffect
*base
= This
->base_effect
;
4226 TRACE("Forward iface %p, base %p\n", This
, base
);
4228 return ID3DXBaseEffectImpl_GetMatrixTranspose(base
, parameter
, matrix
);
4231 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
*matrix
, UINT count
)
4233 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4234 ID3DXBaseEffect
*base
= This
->base_effect
;
4236 TRACE("Forward iface %p, base %p\n", This
, base
);
4238 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base
, parameter
, matrix
, count
);
4241 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
4243 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4244 ID3DXBaseEffect
*base
= This
->base_effect
;
4246 TRACE("Forward iface %p, base %p\n", This
, base
);
4248 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base
, parameter
, matrix
, count
);
4251 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, CONST D3DXMATRIX
**matrix
, UINT count
)
4253 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4254 ID3DXBaseEffect
*base
= This
->base_effect
;
4256 TRACE("Forward iface %p, base %p\n", This
, base
);
4258 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base
, parameter
, matrix
, count
);
4261 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
4263 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4264 ID3DXBaseEffect
*base
= This
->base_effect
;
4266 TRACE("Forward iface %p, base %p\n", This
, base
);
4268 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base
, parameter
, matrix
, count
);
4271 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPCSTR string
)
4273 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4274 ID3DXBaseEffect
*base
= This
->base_effect
;
4276 TRACE("Forward iface %p, base %p\n", This
, base
);
4278 return ID3DXBaseEffectImpl_SetString(base
, parameter
, string
);
4281 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPCSTR
*string
)
4283 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4284 ID3DXBaseEffect
*base
= This
->base_effect
;
4286 TRACE("Forward iface %p, base %p\n", This
, base
);
4288 return ID3DXBaseEffectImpl_GetString(base
, parameter
, string
);
4291 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPDIRECT3DBASETEXTURE9 texture
)
4293 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4294 ID3DXBaseEffect
*base
= This
->base_effect
;
4296 TRACE("Forward iface %p, base %p\n", This
, base
);
4298 return ID3DXBaseEffectImpl_SetTexture(base
, parameter
, texture
);
4301 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPDIRECT3DBASETEXTURE9
*texture
)
4303 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4304 ID3DXBaseEffect
*base
= This
->base_effect
;
4306 TRACE("Forward iface %p, base %p\n", This
, base
);
4308 return ID3DXBaseEffectImpl_GetTexture(base
, parameter
, texture
);
4311 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPDIRECT3DPIXELSHADER9
*pshader
)
4313 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4314 ID3DXBaseEffect
*base
= This
->base_effect
;
4316 TRACE("Forward iface %p, base %p\n", This
, base
);
4318 return ID3DXBaseEffectImpl_GetPixelShader(base
, parameter
, pshader
);
4321 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, LPDIRECT3DVERTEXSHADER9
*vshader
)
4323 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4324 ID3DXBaseEffect
*base
= This
->base_effect
;
4326 TRACE("Forward iface %p, base %p\n", This
, base
);
4328 return ID3DXBaseEffectImpl_GetVertexShader(base
, parameter
, vshader
);
4331 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, UINT start
, UINT end
)
4333 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4334 ID3DXBaseEffect
*base
= This
->base_effect
;
4336 TRACE("Forward iface %p, base %p\n", This
, base
);
4338 return ID3DXBaseEffectImpl_SetArrayRange(base
, parameter
, start
, end
);
4341 /*** ID3DXEffectCompiler methods ***/
4342 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL literal
)
4344 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4346 FIXME("iface %p, parameter %p, literal %u\n", This
, parameter
, literal
);
4351 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL
*literal
)
4353 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4355 FIXME("iface %p, parameter %p, literal %p\n", This
, parameter
, literal
);
4360 static HRESULT WINAPI
ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler
*iface
, DWORD flags
,
4361 LPD3DXBUFFER
*effect
, LPD3DXBUFFER
*error_msgs
)
4363 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4365 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This
, flags
, effect
, error_msgs
);
4370 static HRESULT WINAPI
ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler
*iface
, D3DXHANDLE function
,
4371 LPCSTR target
, DWORD flags
, LPD3DXBUFFER
*shader
, LPD3DXBUFFER
*error_msgs
, LPD3DXCONSTANTTABLE
*constant_table
)
4373 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4375 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
4376 This
, function
, target
, flags
, shader
, error_msgs
, constant_table
);
4381 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl
=
4383 /*** IUnknown methods ***/
4384 ID3DXEffectCompilerImpl_QueryInterface
,
4385 ID3DXEffectCompilerImpl_AddRef
,
4386 ID3DXEffectCompilerImpl_Release
,
4387 /*** ID3DXBaseEffect methods ***/
4388 ID3DXEffectCompilerImpl_GetDesc
,
4389 ID3DXEffectCompilerImpl_GetParameterDesc
,
4390 ID3DXEffectCompilerImpl_GetTechniqueDesc
,
4391 ID3DXEffectCompilerImpl_GetPassDesc
,
4392 ID3DXEffectCompilerImpl_GetFunctionDesc
,
4393 ID3DXEffectCompilerImpl_GetParameter
,
4394 ID3DXEffectCompilerImpl_GetParameterByName
,
4395 ID3DXEffectCompilerImpl_GetParameterBySemantic
,
4396 ID3DXEffectCompilerImpl_GetParameterElement
,
4397 ID3DXEffectCompilerImpl_GetTechnique
,
4398 ID3DXEffectCompilerImpl_GetTechniqueByName
,
4399 ID3DXEffectCompilerImpl_GetPass
,
4400 ID3DXEffectCompilerImpl_GetPassByName
,
4401 ID3DXEffectCompilerImpl_GetFunction
,
4402 ID3DXEffectCompilerImpl_GetFunctionByName
,
4403 ID3DXEffectCompilerImpl_GetAnnotation
,
4404 ID3DXEffectCompilerImpl_GetAnnotationByName
,
4405 ID3DXEffectCompilerImpl_SetValue
,
4406 ID3DXEffectCompilerImpl_GetValue
,
4407 ID3DXEffectCompilerImpl_SetBool
,
4408 ID3DXEffectCompilerImpl_GetBool
,
4409 ID3DXEffectCompilerImpl_SetBoolArray
,
4410 ID3DXEffectCompilerImpl_GetBoolArray
,
4411 ID3DXEffectCompilerImpl_SetInt
,
4412 ID3DXEffectCompilerImpl_GetInt
,
4413 ID3DXEffectCompilerImpl_SetIntArray
,
4414 ID3DXEffectCompilerImpl_GetIntArray
,
4415 ID3DXEffectCompilerImpl_SetFloat
,
4416 ID3DXEffectCompilerImpl_GetFloat
,
4417 ID3DXEffectCompilerImpl_SetFloatArray
,
4418 ID3DXEffectCompilerImpl_GetFloatArray
,
4419 ID3DXEffectCompilerImpl_SetVector
,
4420 ID3DXEffectCompilerImpl_GetVector
,
4421 ID3DXEffectCompilerImpl_SetVectorArray
,
4422 ID3DXEffectCompilerImpl_GetVectorArray
,
4423 ID3DXEffectCompilerImpl_SetMatrix
,
4424 ID3DXEffectCompilerImpl_GetMatrix
,
4425 ID3DXEffectCompilerImpl_SetMatrixArray
,
4426 ID3DXEffectCompilerImpl_GetMatrixArray
,
4427 ID3DXEffectCompilerImpl_SetMatrixPointerArray
,
4428 ID3DXEffectCompilerImpl_GetMatrixPointerArray
,
4429 ID3DXEffectCompilerImpl_SetMatrixTranspose
,
4430 ID3DXEffectCompilerImpl_GetMatrixTranspose
,
4431 ID3DXEffectCompilerImpl_SetMatrixTransposeArray
,
4432 ID3DXEffectCompilerImpl_GetMatrixTransposeArray
,
4433 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray
,
4434 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray
,
4435 ID3DXEffectCompilerImpl_SetString
,
4436 ID3DXEffectCompilerImpl_GetString
,
4437 ID3DXEffectCompilerImpl_SetTexture
,
4438 ID3DXEffectCompilerImpl_GetTexture
,
4439 ID3DXEffectCompilerImpl_GetPixelShader
,
4440 ID3DXEffectCompilerImpl_GetVertexShader
,
4441 ID3DXEffectCompilerImpl_SetArrayRange
,
4442 /*** ID3DXEffectCompiler methods ***/
4443 ID3DXEffectCompilerImpl_SetLiteral
,
4444 ID3DXEffectCompilerImpl_GetLiteral
,
4445 ID3DXEffectCompilerImpl_CompileEffect
,
4446 ID3DXEffectCompilerImpl_CompileShader
,
4449 static HRESULT
d3dx9_parse_sampler(struct d3dx_sampler
*sampler
, const char *data
, const char **ptr
, D3DXHANDLE
*objects
)
4453 struct d3dx_state
*states
;
4455 read_dword(ptr
, &sampler
->state_count
);
4456 TRACE("Count: %u\n", sampler
->state_count
);
4458 states
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*states
) * sampler
->state_count
);
4461 ERR("Out of memory\n");
4462 return E_OUTOFMEMORY
;
4465 for (i
= 0; i
< sampler
->state_count
; ++i
)
4467 hr
= d3dx9_parse_state(&states
[i
], data
, ptr
, objects
);
4470 WARN("Failed to parse state\n");
4475 sampler
->states
= states
;
4481 for (i
= 0; i
< sampler
->state_count
; ++i
)
4483 free_state(&states
[i
]);
4486 HeapFree(GetProcessHeap(), 0, states
);
4491 static HRESULT
d3dx9_parse_value(struct d3dx_parameter
*param
, void *value
, const char *data
, const char **ptr
, D3DXHANDLE
*objects
)
4498 if (param
->element_count
)
4500 param
->data
= value
;
4502 for (i
= 0; i
< param
->element_count
; ++i
)
4504 struct d3dx_parameter
*member
= get_parameter_struct(param
->member_handles
[i
]);
4506 hr
= d3dx9_parse_value(member
, value
? (char *)value
+ old_size
: NULL
, data
, ptr
, objects
);
4509 WARN("Failed to parse value\n");
4513 old_size
+= member
->bytes
;
4519 switch(param
->class)
4523 case D3DXPC_MATRIX_ROWS
:
4524 case D3DXPC_MATRIX_COLUMNS
:
4525 param
->data
= value
;
4529 param
->data
= value
;
4531 for (i
= 0; i
< param
->member_count
; ++i
)
4533 struct d3dx_parameter
*member
= get_parameter_struct(param
->member_handles
[i
]);
4535 hr
= d3dx9_parse_value(member
, (char *)value
+ old_size
, data
, ptr
, objects
);
4538 WARN("Failed to parse value\n");
4542 old_size
+= member
->bytes
;
4547 switch (param
->type
)
4550 case D3DXPT_TEXTURE
:
4551 case D3DXPT_TEXTURE1D
:
4552 case D3DXPT_TEXTURE2D
:
4553 case D3DXPT_TEXTURE3D
:
4554 case D3DXPT_TEXTURECUBE
:
4555 case D3DXPT_PIXELSHADER
:
4556 case D3DXPT_VERTEXSHADER
:
4557 read_dword(ptr
, &id
);
4558 TRACE("Id: %u\n", id
);
4559 objects
[id
] = get_parameter_handle(param
);
4560 param
->data
= value
;
4563 case D3DXPT_SAMPLER
:
4564 case D3DXPT_SAMPLER1D
:
4565 case D3DXPT_SAMPLER2D
:
4566 case D3DXPT_SAMPLER3D
:
4567 case D3DXPT_SAMPLERCUBE
:
4569 struct d3dx_sampler
*sampler
;
4571 sampler
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*sampler
));
4574 ERR("Out of memory\n");
4575 return E_OUTOFMEMORY
;
4578 hr
= d3dx9_parse_sampler(sampler
, data
, ptr
, objects
);
4581 HeapFree(GetProcessHeap(), 0, sampler
);
4582 WARN("Failed to parse sampler\n");
4586 param
->data
= sampler
;
4591 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
4597 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
4604 static HRESULT
d3dx9_parse_init_value(struct d3dx_parameter
*param
, const char *data
, const char *ptr
, D3DXHANDLE
*objects
)
4606 UINT size
= param
->bytes
;
4610 TRACE("param size: %u\n", size
);
4614 value
= HeapAlloc(GetProcessHeap(), 0, size
);
4617 ERR("Failed to allocate data memory.\n");
4618 return E_OUTOFMEMORY
;
4621 TRACE("Data: %s.\n", debugstr_an(ptr
, size
));
4622 memcpy(value
, ptr
, size
);
4625 hr
= d3dx9_parse_value(param
, value
, data
, &ptr
, objects
);
4628 WARN("Failed to parse value\n");
4629 HeapFree(GetProcessHeap(), 0, value
);
4636 static HRESULT
d3dx9_parse_name(char **name
, const char *ptr
)
4640 read_dword(&ptr
, &size
);
4641 TRACE("Name size: %#x\n", size
);
4648 *name
= HeapAlloc(GetProcessHeap(), 0, size
);
4651 ERR("Failed to allocate name memory.\n");
4652 return E_OUTOFMEMORY
;
4655 TRACE("Name: %s.\n", debugstr_an(ptr
, size
));
4656 memcpy(*name
, ptr
, size
);
4661 static HRESULT
d3dx9_copy_data(char **str
, const char **ptr
)
4665 read_dword(ptr
, &size
);
4666 TRACE("Data size: %#x\n", size
);
4668 *str
= HeapAlloc(GetProcessHeap(), 0, size
);
4671 ERR("Failed to allocate name memory.\n");
4672 return E_OUTOFMEMORY
;
4675 TRACE("Data: %s.\n", debugstr_an(*ptr
, size
));
4676 memcpy(*str
, *ptr
, size
);
4678 *ptr
+= ((size
+ 3) & ~3);
4683 static HRESULT
d3dx9_parse_data(struct d3dx_parameter
*param
, const char **ptr
, LPDIRECT3DDEVICE9 device
)
4688 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param
->name
), debug_d3dxparameter_type(param
->type
));
4690 read_dword(ptr
, &size
);
4691 TRACE("Data size: %#x\n", size
);
4695 TRACE("Size is 0\n");
4696 *(void **)param
->data
= NULL
;
4700 switch (param
->type
)
4703 /* re-read with size (sizeof(DWORD) = 4) */
4704 hr
= d3dx9_parse_name((LPSTR
*)param
->data
, *ptr
- 4);
4707 WARN("Failed to parse string data\n");
4712 case D3DXPT_VERTEXSHADER
:
4713 hr
= IDirect3DDevice9_CreateVertexShader(device
, (DWORD
*)*ptr
, (LPDIRECT3DVERTEXSHADER9
*)param
->data
);
4716 WARN("Failed to create vertex shader\n");
4721 case D3DXPT_PIXELSHADER
:
4722 hr
= IDirect3DDevice9_CreatePixelShader(device
, (DWORD
*)*ptr
, (LPDIRECT3DPIXELSHADER9
*)param
->data
);
4725 WARN("Failed to create pixel shader\n");
4731 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
4736 *ptr
+= ((size
+ 3) & ~3);
4741 static HRESULT
d3dx9_parse_effect_typedef(struct d3dx_parameter
*param
, const char *data
, const char **ptr
,
4742 struct d3dx_parameter
*parent
, UINT flags
)
4746 D3DXHANDLE
*member_handles
= NULL
;
4749 param
->flags
= flags
;
4753 read_dword(ptr
, ¶m
->type
);
4754 TRACE("Type: %s\n", debug_d3dxparameter_type(param
->type
));
4756 read_dword(ptr
, ¶m
->class);
4757 TRACE("Class: %s\n", debug_d3dxparameter_class(param
->class));
4759 read_dword(ptr
, &offset
);
4760 TRACE("Type name offset: %#x\n", offset
);
4761 hr
= d3dx9_parse_name(¶m
->name
, data
+ offset
);
4764 WARN("Failed to parse name\n");
4768 read_dword(ptr
, &offset
);
4769 TRACE("Type semantic offset: %#x\n", offset
);
4770 hr
= d3dx9_parse_name(¶m
->semantic
, data
+ offset
);
4773 WARN("Failed to parse semantic\n");
4777 read_dword(ptr
, ¶m
->element_count
);
4778 TRACE("Elements: %u\n", param
->element_count
);
4780 switch (param
->class)
4783 read_dword(ptr
, ¶m
->columns
);
4784 TRACE("Columns: %u\n", param
->columns
);
4786 read_dword(ptr
, ¶m
->rows
);
4787 TRACE("Rows: %u\n", param
->rows
);
4789 /* sizeof(DWORD) * rows * columns */
4790 param
->bytes
= 4 * param
->rows
* param
->columns
;
4794 case D3DXPC_MATRIX_ROWS
:
4795 case D3DXPC_MATRIX_COLUMNS
:
4796 read_dword(ptr
, ¶m
->rows
);
4797 TRACE("Rows: %u\n", param
->rows
);
4799 read_dword(ptr
, ¶m
->columns
);
4800 TRACE("Columns: %u\n", param
->columns
);
4802 /* sizeof(DWORD) * rows * columns */
4803 param
->bytes
= 4 * param
->rows
* param
->columns
;
4807 read_dword(ptr
, ¶m
->member_count
);
4808 TRACE("Members: %u\n", param
->member_count
);
4812 switch (param
->type
)
4815 param
->bytes
= sizeof(LPCSTR
);
4818 case D3DXPT_PIXELSHADER
:
4819 param
->bytes
= sizeof(LPDIRECT3DPIXELSHADER9
);
4822 case D3DXPT_VERTEXSHADER
:
4823 param
->bytes
= sizeof(LPDIRECT3DVERTEXSHADER9
);
4826 case D3DXPT_TEXTURE
:
4827 case D3DXPT_TEXTURE1D
:
4828 case D3DXPT_TEXTURE2D
:
4829 case D3DXPT_TEXTURE3D
:
4830 case D3DXPT_TEXTURECUBE
:
4831 param
->bytes
= sizeof(LPDIRECT3DBASETEXTURE9
);
4834 case D3DXPT_SAMPLER
:
4835 case D3DXPT_SAMPLER1D
:
4836 case D3DXPT_SAMPLER2D
:
4837 case D3DXPT_SAMPLER3D
:
4838 case D3DXPT_SAMPLERCUBE
:
4843 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
4849 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
4856 param
->type
= parent
->type
;
4857 param
->class = parent
->class;
4858 param
->name
= parent
->name
;
4859 param
->semantic
= parent
->semantic
;
4860 param
->element_count
= 0;
4861 param
->annotation_count
= 0;
4862 param
->member_count
= parent
->member_count
;
4863 param
->bytes
= parent
->bytes
;
4864 param
->rows
= parent
->rows
;
4865 param
->columns
= parent
->columns
;
4868 if (param
->element_count
)
4870 unsigned int param_bytes
= 0;
4871 const char *save_ptr
= *ptr
;
4873 member_handles
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*member_handles
) * param
->element_count
);
4874 if (!member_handles
)
4876 ERR("Out of memory\n");
4881 for (i
= 0; i
< param
->element_count
; ++i
)
4883 struct d3dx_parameter
*member
;
4886 member
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*member
));
4889 ERR("Out of memory\n");
4894 member_handles
[i
] = get_parameter_handle(member
);
4896 hr
= d3dx9_parse_effect_typedef(member
, data
, ptr
, param
, flags
);
4899 WARN("Failed to parse member\n");
4903 param_bytes
+= member
->bytes
;
4906 param
->bytes
= param_bytes
;
4908 else if (param
->member_count
)
4910 member_handles
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*member_handles
) * param
->member_count
);
4911 if (!member_handles
)
4913 ERR("Out of memory\n");
4918 for (i
= 0; i
< param
->member_count
; ++i
)
4920 struct d3dx_parameter
*member
;
4922 member
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*member
));
4925 ERR("Out of memory\n");
4930 member_handles
[i
] = get_parameter_handle(member
);
4932 hr
= d3dx9_parse_effect_typedef(member
, data
, ptr
, NULL
, flags
);
4935 WARN("Failed to parse member\n");
4939 param
->bytes
+= member
->bytes
;
4943 param
->member_handles
= member_handles
;
4953 if (param
->element_count
) count
= param
->element_count
;
4954 else count
= param
->member_count
;
4956 for (i
= 0; i
< count
; ++i
)
4958 free_parameter(member_handles
[i
], param
->element_count
!= 0, TRUE
);
4960 HeapFree(GetProcessHeap(), 0, member_handles
);
4965 HeapFree(GetProcessHeap(), 0, param
->name
);
4966 HeapFree(GetProcessHeap(), 0, param
->semantic
);
4969 param
->semantic
= NULL
;
4974 static HRESULT
d3dx9_parse_effect_annotation(struct d3dx_parameter
*anno
, const char *data
, const char **ptr
, D3DXHANDLE
*objects
)
4980 anno
->flags
= D3DX_PARAMETER_ANNOTATION
;
4982 read_dword(ptr
, &offset
);
4983 TRACE("Typedef offset: %#x\n", offset
);
4984 ptr2
= data
+ offset
;
4985 hr
= d3dx9_parse_effect_typedef(anno
, data
, &ptr2
, NULL
, D3DX_PARAMETER_ANNOTATION
);
4988 WARN("Failed to parse type definition\n");
4992 read_dword(ptr
, &offset
);
4993 TRACE("Value offset: %#x\n", offset
);
4994 hr
= d3dx9_parse_init_value(anno
, data
, data
+ offset
, objects
);
4997 WARN("Failed to parse value\n");
5004 static HRESULT
d3dx9_parse_state(struct d3dx_state
*state
, const char *data
, const char **ptr
, D3DXHANDLE
*objects
)
5009 struct d3dx_parameter
*parameter
;
5011 parameter
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*parameter
));
5014 ERR("Out of memory\n");
5015 return E_OUTOFMEMORY
;
5018 state
->type
= ST_CONSTANT
;
5020 read_dword(ptr
, &state
->operation
);
5021 TRACE("Operation: %#x (%s)\n", state
->operation
, state_table
[state
->operation
].name
);
5023 read_dword(ptr
, &state
->index
);
5024 TRACE("Index: %#x\n", state
->index
);
5026 read_dword(ptr
, &offset
);
5027 TRACE("Typedef offset: %#x\n", offset
);
5028 ptr2
= data
+ offset
;
5029 hr
= d3dx9_parse_effect_typedef(parameter
, data
, &ptr2
, NULL
, 0);
5032 WARN("Failed to parse type definition\n");
5036 read_dword(ptr
, &offset
);
5037 TRACE("Value offset: %#x\n", offset
);
5038 hr
= d3dx9_parse_init_value(parameter
, data
, data
+ offset
, objects
);
5041 WARN("Failed to parse value\n");
5045 state
->parameter
= get_parameter_handle(parameter
);
5051 free_parameter(get_parameter_handle(parameter
), FALSE
, FALSE
);
5056 static HRESULT
d3dx9_parse_effect_parameter(struct d3dx_parameter
*param
, const char *data
, const char **ptr
, D3DXHANDLE
*objects
)
5061 D3DXHANDLE
*annotation_handles
= NULL
;
5064 read_dword(ptr
, &offset
);
5065 TRACE("Typedef offset: %#x\n", offset
);
5066 ptr2
= data
+ offset
;
5068 read_dword(ptr
, &offset
);
5069 TRACE("Value offset: %#x\n", offset
);
5071 read_dword(ptr
, ¶m
->flags
);
5072 TRACE("Flags: %#x\n", param
->flags
);
5074 read_dword(ptr
, ¶m
->annotation_count
);
5075 TRACE("Annotation count: %u\n", param
->annotation_count
);
5077 hr
= d3dx9_parse_effect_typedef(param
, data
, &ptr2
, NULL
, param
->flags
);
5080 WARN("Failed to parse type definition\n");
5084 hr
= d3dx9_parse_init_value(param
, data
, data
+ offset
, objects
);
5087 WARN("Failed to parse value\n");
5091 if (param
->annotation_count
)
5093 annotation_handles
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*annotation_handles
) * param
->annotation_count
);
5094 if (!annotation_handles
)
5096 ERR("Out of memory\n");
5101 for (i
= 0; i
< param
->annotation_count
; ++i
)
5103 struct d3dx_parameter
*annotation
;
5105 annotation
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*annotation
));
5108 ERR("Out of memory\n");
5113 annotation_handles
[i
] = get_parameter_handle(annotation
);
5115 hr
= d3dx9_parse_effect_annotation(annotation
, data
, ptr
, objects
);
5118 WARN("Failed to parse annotation\n");
5124 param
->annotation_handles
= annotation_handles
;
5130 if (annotation_handles
)
5132 for (i
= 0; i
< param
->annotation_count
; ++i
)
5134 free_parameter(annotation_handles
[i
], FALSE
, FALSE
);
5136 HeapFree(GetProcessHeap(), 0, annotation_handles
);
5142 static HRESULT
d3dx9_parse_effect_pass(struct d3dx_pass
*pass
, const char *data
, const char **ptr
, D3DXHANDLE
*objects
)
5147 D3DXHANDLE
*annotation_handles
= NULL
;
5148 struct d3dx_state
*states
= NULL
;
5151 read_dword(ptr
, &offset
);
5152 TRACE("Pass name offset: %#x\n", offset
);
5153 hr
= d3dx9_parse_name(&name
, data
+ offset
);
5156 WARN("Failed to parse name\n");
5160 read_dword(ptr
, &pass
->annotation_count
);
5161 TRACE("Annotation count: %u\n", pass
->annotation_count
);
5163 read_dword(ptr
, &pass
->state_count
);
5164 TRACE("State count: %u\n", pass
->state_count
);
5166 if (pass
->annotation_count
)
5168 annotation_handles
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*annotation_handles
) * pass
->annotation_count
);
5169 if (!annotation_handles
)
5171 ERR("Out of memory\n");
5176 for (i
= 0; i
< pass
->annotation_count
; ++i
)
5178 struct d3dx_parameter
*annotation
;
5180 annotation
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*annotation
));
5183 ERR("Out of memory\n");
5188 annotation_handles
[i
] = get_parameter_handle(annotation
);
5190 hr
= d3dx9_parse_effect_annotation(annotation
, data
, ptr
, objects
);
5193 WARN("Failed to parse annotations\n");
5199 if (pass
->state_count
)
5201 states
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*states
) * pass
->state_count
);
5204 ERR("Out of memory\n");
5209 for (i
= 0; i
< pass
->state_count
; ++i
)
5211 hr
= d3dx9_parse_state(&states
[i
], data
, ptr
, objects
);
5214 WARN("Failed to parse annotations\n");
5221 pass
->annotation_handles
= annotation_handles
;
5222 pass
->states
= states
;
5228 if (annotation_handles
)
5230 for (i
= 0; i
< pass
->annotation_count
; ++i
)
5232 free_parameter(annotation_handles
[i
], FALSE
, FALSE
);
5234 HeapFree(GetProcessHeap(), 0, annotation_handles
);
5239 for (i
= 0; i
< pass
->state_count
; ++i
)
5241 free_state(&states
[i
]);
5243 HeapFree(GetProcessHeap(), 0, states
);
5246 HeapFree(GetProcessHeap(), 0, name
);
5251 static HRESULT
d3dx9_parse_effect_technique(struct d3dx_technique
*technique
, const char *data
, const char **ptr
, D3DXHANDLE
*objects
)
5256 D3DXHANDLE
*annotation_handles
= NULL
;
5257 D3DXHANDLE
*pass_handles
= NULL
;
5260 read_dword(ptr
, &offset
);
5261 TRACE("Technique name offset: %#x\n", offset
);
5262 hr
= d3dx9_parse_name(&name
, data
+ offset
);
5265 WARN("Failed to parse name\n");
5269 read_dword(ptr
, &technique
->annotation_count
);
5270 TRACE("Annotation count: %u\n", technique
->annotation_count
);
5272 read_dword(ptr
, &technique
->pass_count
);
5273 TRACE("Pass count: %u\n", technique
->pass_count
);
5275 if (technique
->annotation_count
)
5277 annotation_handles
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*annotation_handles
) * technique
->annotation_count
);
5278 if (!annotation_handles
)
5280 ERR("Out of memory\n");
5285 for (i
= 0; i
< technique
->annotation_count
; ++i
)
5287 struct d3dx_parameter
*annotation
;
5289 annotation
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*annotation
));
5292 ERR("Out of memory\n");
5297 annotation_handles
[i
] = get_parameter_handle(annotation
);
5299 hr
= d3dx9_parse_effect_annotation(annotation
, data
, ptr
, objects
);
5302 WARN("Failed to parse annotations\n");
5308 if (technique
->pass_count
)
5310 pass_handles
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*pass_handles
) * technique
->pass_count
);
5313 ERR("Out of memory\n");
5318 for (i
= 0; i
< technique
->pass_count
; ++i
)
5320 struct d3dx_pass
*pass
;
5322 pass
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*pass
));
5325 ERR("Out of memory\n");
5330 pass_handles
[i
] = get_pass_handle(pass
);
5332 hr
= d3dx9_parse_effect_pass(pass
, data
, ptr
, objects
);
5335 WARN("Failed to parse passes\n");
5341 technique
->name
= name
;
5342 technique
->pass_handles
= pass_handles
;
5343 technique
->annotation_handles
= annotation_handles
;
5351 for (i
= 0; i
< technique
->pass_count
; ++i
)
5353 free_pass(pass_handles
[i
]);
5355 HeapFree(GetProcessHeap(), 0, pass_handles
);
5358 if (annotation_handles
)
5360 for (i
= 0; i
< technique
->annotation_count
; ++i
)
5362 free_parameter(annotation_handles
[i
], FALSE
, FALSE
);
5364 HeapFree(GetProcessHeap(), 0, annotation_handles
);
5367 HeapFree(GetProcessHeap(), 0, name
);
5372 static HRESULT
d3dx9_parse_resource(struct ID3DXBaseEffectImpl
*base
, const char *data
, const char **ptr
)
5374 DWORD technique_index
;
5375 DWORD index
, state_index
, usage
, element_index
;
5376 struct d3dx_state
*state
;
5377 struct d3dx_parameter
*param
;
5378 HRESULT hr
= E_FAIL
;
5380 read_dword(ptr
, &technique_index
);
5381 TRACE("techn: %u\n", technique_index
);
5383 read_dword(ptr
, &index
);
5384 TRACE("index: %u\n", index
);
5386 read_dword(ptr
, &element_index
);
5387 TRACE("element_index: %u\n", element_index
);
5389 read_dword(ptr
, &state_index
);
5390 TRACE("state_index: %u\n", state_index
);
5392 read_dword(ptr
, &usage
);
5393 TRACE("usage: %u\n", usage
);
5395 if (technique_index
== 0xffffffff)
5397 struct d3dx_parameter
*parameter
;
5398 struct d3dx_sampler
*sampler
;
5400 if (index
>= base
->parameter_count
)
5402 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index
, base
->parameter_count
);
5406 parameter
= get_parameter_struct(base
->parameter_handles
[index
]);
5407 if (element_index
!= 0xffffffff)
5409 if (element_index
>= parameter
->element_count
&& parameter
->element_count
!= 0)
5411 FIXME("Index out of bounds: element_index %u >= element_count %u\n", element_index
, parameter
->element_count
);
5415 if (parameter
->element_count
!= 0) parameter
= get_parameter_struct(parameter
->member_handles
[element_index
]);
5418 sampler
= parameter
->data
;
5419 if (state_index
>= sampler
->state_count
)
5421 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index
, sampler
->state_count
);
5425 state
= &sampler
->states
[state_index
];
5429 struct d3dx_technique
*technique
;
5430 struct d3dx_pass
*pass
;
5432 if (technique_index
>= base
->technique_count
)
5434 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index
, base
->technique_count
);
5438 technique
= get_technique_struct(base
->technique_handles
[technique_index
]);
5439 if (index
>= technique
->pass_count
)
5441 FIXME("Index out of bounds: index %u >= pass_count %u\n", index
, technique
->pass_count
);
5445 pass
= get_pass_struct(technique
->pass_handles
[index
]);
5446 if (state_index
>= pass
->state_count
)
5448 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index
, pass
->state_count
);
5452 state
= &pass
->states
[state_index
];
5455 param
= get_parameter_struct(state
->parameter
);
5460 TRACE("usage 0: type %s\n", debug_d3dxparameter_type(param
->type
));
5461 switch (param
->type
)
5463 case D3DXPT_VERTEXSHADER
:
5464 case D3DXPT_PIXELSHADER
:
5465 state
->type
= ST_CONSTANT
;
5466 hr
= d3dx9_parse_data(param
, ptr
, base
->effect
->device
);
5473 state
->type
= ST_FXLC
;
5474 hr
= d3dx9_copy_data(param
->data
, ptr
);
5478 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
5484 state
->type
= ST_PARAMETER
;
5485 hr
= d3dx9_copy_data(param
->data
, ptr
);
5488 TRACE("Mapping to parameter %s\n", *(char **)param
->data
);
5493 FIXME("Unknown usage %x\n", usage
);
5500 static HRESULT
d3dx9_parse_effect(struct ID3DXBaseEffectImpl
*base
, const char *data
, UINT data_size
, DWORD start
)
5502 const char *ptr
= data
+ start
;
5503 D3DXHANDLE
*parameter_handles
= NULL
;
5504 D3DXHANDLE
*technique_handles
= NULL
;
5505 D3DXHANDLE
*objects
= NULL
;
5506 UINT stringcount
, objectcount
, resourcecount
;
5510 read_dword(&ptr
, &base
->parameter_count
);
5511 TRACE("Parameter count: %u\n", base
->parameter_count
);
5513 read_dword(&ptr
, &base
->technique_count
);
5514 TRACE("Technique count: %u\n", base
->technique_count
);
5516 skip_dword_unknown(&ptr
, 1);
5518 read_dword(&ptr
, &objectcount
);
5519 TRACE("Object count: %u\n", objectcount
);
5521 objects
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*objects
) * objectcount
);
5524 ERR("Out of memory\n");
5529 if (base
->parameter_count
)
5531 parameter_handles
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*parameter_handles
) * base
->parameter_count
);
5532 if (!parameter_handles
)
5534 ERR("Out of memory\n");
5539 for (i
= 0; i
< base
->parameter_count
; ++i
)
5541 struct d3dx_parameter
*parameter
;
5543 parameter
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*parameter
));
5546 ERR("Out of memory\n");
5551 parameter_handles
[i
] = get_parameter_handle(parameter
);
5553 hr
= d3dx9_parse_effect_parameter(parameter
, data
, &ptr
, objects
);
5556 WARN("Failed to parse parameter\n");
5562 if (base
->technique_count
)
5564 technique_handles
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*technique_handles
) * base
->technique_count
);
5565 if (!technique_handles
)
5567 ERR("Out of memory\n");
5572 for (i
= 0; i
< base
->technique_count
; ++i
)
5574 struct d3dx_technique
*technique
;
5576 technique
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*technique
));
5579 ERR("Out of memory\n");
5584 technique_handles
[i
] = get_technique_handle(technique
);
5586 hr
= d3dx9_parse_effect_technique(technique
, data
, &ptr
, objects
);
5589 WARN("Failed to parse technique\n");
5595 /* needed for further parsing */
5596 base
->technique_handles
= technique_handles
;
5597 base
->parameter_handles
= parameter_handles
;
5599 read_dword(&ptr
, &stringcount
);
5600 TRACE("String count: %u\n", stringcount
);
5602 read_dword(&ptr
, &resourcecount
);
5603 TRACE("Resource count: %u\n", resourcecount
);
5605 for (i
= 0; i
< stringcount
; ++i
)
5608 struct d3dx_parameter
*param
;
5610 read_dword(&ptr
, &id
);
5611 TRACE("Id: %u\n", id
);
5613 param
= get_parameter_struct(objects
[id
]);
5615 hr
= d3dx9_parse_data(param
, &ptr
, base
->effect
->device
);
5618 WARN("Failed to parse data\n");
5623 for (i
= 0; i
< resourcecount
; ++i
)
5625 TRACE("parse resource %u\n", i
);
5627 hr
= d3dx9_parse_resource(base
, data
, &ptr
);
5630 WARN("Failed to parse data\n");
5635 HeapFree(GetProcessHeap(), 0, objects
);
5641 if (technique_handles
)
5643 for (i
= 0; i
< base
->technique_count
; ++i
)
5645 free_technique(technique_handles
[i
]);
5647 HeapFree(GetProcessHeap(), 0, technique_handles
);
5650 if (parameter_handles
)
5652 for (i
= 0; i
< base
->parameter_count
; ++i
)
5654 free_parameter(parameter_handles
[i
], FALSE
, FALSE
);
5656 HeapFree(GetProcessHeap(), 0, parameter_handles
);
5659 base
->technique_handles
= NULL
;
5660 base
->parameter_handles
= NULL
;
5662 HeapFree(GetProcessHeap(), 0, objects
);
5667 static HRESULT
d3dx9_base_effect_init(struct ID3DXBaseEffectImpl
*base
,
5668 const char *data
, SIZE_T data_size
, struct ID3DXEffectImpl
*effect
)
5671 const char *ptr
= data
;
5674 TRACE("base %p, data %p, data_size %lu, effect %p\n", base
, data
, data_size
, effect
);
5676 base
->ID3DXBaseEffect_iface
.lpVtbl
= &ID3DXBaseEffect_Vtbl
;
5678 base
->effect
= effect
;
5680 read_dword(&ptr
, &tag
);
5681 TRACE("Tag: %x\n", tag
);
5683 if (tag
!= d3dx9_effect_version(9, 1))
5685 /* todo: compile hlsl ascii code */
5686 FIXME("HLSL ascii effects not supported, yet\n");
5688 /* Show the start of the shader for debugging info. */
5689 TRACE("effect:\n%s\n", debugstr_an(data
, data_size
> 40 ? 40 : data_size
));
5693 read_dword(&ptr
, &offset
);
5694 TRACE("Offset: %x\n", offset
);
5696 hr
= d3dx9_parse_effect(base
, ptr
, data_size
, offset
);
5699 FIXME("Failed to parse effect.\n");
5707 static HRESULT
d3dx9_effect_init(struct ID3DXEffectImpl
*effect
, LPDIRECT3DDEVICE9 device
,
5708 const char *data
, SIZE_T data_size
, LPD3DXEFFECTPOOL pool
)
5711 struct ID3DXBaseEffectImpl
*object
= NULL
;
5713 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect
, device
, data
, data_size
, pool
);
5715 effect
->ID3DXEffect_iface
.lpVtbl
= &ID3DXEffect_Vtbl
;
5718 if (pool
) pool
->lpVtbl
->AddRef(pool
);
5719 effect
->pool
= pool
;
5721 IDirect3DDevice9_AddRef(device
);
5722 effect
->device
= device
;
5724 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
5727 ERR("Out of memory\n");
5732 hr
= d3dx9_base_effect_init(object
, data
, data_size
, effect
);
5735 FIXME("Failed to parse effect.\n");
5739 effect
->base_effect
= &object
->ID3DXBaseEffect_iface
;
5741 /* initialize defaults - check because of unsupported ascii effects */
5742 if (object
->technique_handles
)
5744 effect
->active_technique
= object
->technique_handles
[0];
5745 effect
->active_pass
= NULL
;
5752 HeapFree(GetProcessHeap(), 0, object
);
5753 free_effect(effect
);
5758 HRESULT WINAPI
D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device
,
5761 CONST D3DXMACRO
* defines
,
5762 LPD3DXINCLUDE include
,
5763 LPCSTR skip_constants
,
5765 LPD3DXEFFECTPOOL pool
,
5766 LPD3DXEFFECT
* effect
,
5767 LPD3DXBUFFER
* compilation_errors
)
5769 struct ID3DXEffectImpl
*object
;
5772 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device
, srcdata
, srcdatalen
, defines
, include
,
5773 skip_constants
, flags
, pool
, effect
, compilation_errors
);
5775 if (!device
|| !srcdata
)
5776 return D3DERR_INVALIDCALL
;
5781 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5785 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
5788 ERR("Out of memory\n");
5789 return E_OUTOFMEMORY
;
5792 hr
= d3dx9_effect_init(object
, device
, srcdata
, srcdatalen
, pool
);
5795 WARN("Failed to initialize shader reflection\n");
5796 HeapFree(GetProcessHeap(), 0, object
);
5800 *effect
= &object
->ID3DXEffect_iface
;
5802 TRACE("Created ID3DXEffect %p\n", object
);
5807 HRESULT WINAPI
D3DXCreateEffect(LPDIRECT3DDEVICE9 device
,
5810 CONST D3DXMACRO
* defines
,
5811 LPD3DXINCLUDE include
,
5813 LPD3DXEFFECTPOOL pool
,
5814 LPD3DXEFFECT
* effect
,
5815 LPD3DXBUFFER
* compilation_errors
)
5817 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device
, srcdata
, srcdatalen
, defines
,
5818 include
, flags
, pool
, effect
, compilation_errors
);
5820 return D3DXCreateEffectEx(device
, srcdata
, srcdatalen
, defines
, include
, NULL
, flags
, pool
, effect
, compilation_errors
);
5823 static HRESULT
d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl
*compiler
, const char *data
, SIZE_T data_size
)
5826 struct ID3DXBaseEffectImpl
*object
= NULL
;
5828 TRACE("effect %p, data %p, data_size %lu\n", compiler
, data
, data_size
);
5830 compiler
->ID3DXEffectCompiler_iface
.lpVtbl
= &ID3DXEffectCompiler_Vtbl
;
5833 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
5836 ERR("Out of memory\n");
5841 hr
= d3dx9_base_effect_init(object
, data
, data_size
, NULL
);
5844 FIXME("Failed to parse effect.\n");
5848 compiler
->base_effect
= &object
->ID3DXBaseEffect_iface
;
5854 HeapFree(GetProcessHeap(), 0, object
);
5855 free_effect_compiler(compiler
);
5860 HRESULT WINAPI
D3DXCreateEffectCompiler(LPCSTR srcdata
,
5862 CONST D3DXMACRO
*defines
,
5863 LPD3DXINCLUDE include
,
5865 LPD3DXEFFECTCOMPILER
*compiler
,
5866 LPD3DXBUFFER
*parse_errors
)
5868 struct ID3DXEffectCompilerImpl
*object
;
5871 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5872 srcdata
, srcdatalen
, defines
, include
, flags
, compiler
, parse_errors
);
5874 if (!srcdata
|| !compiler
)
5876 WARN("Invalid arguments supplied\n");
5877 return D3DERR_INVALIDCALL
;
5880 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
5883 ERR("Out of memory\n");
5884 return E_OUTOFMEMORY
;
5887 hr
= d3dx9_effect_compiler_init(object
, srcdata
, srcdatalen
);
5890 WARN("Failed to initialize effect compiler\n");
5891 HeapFree(GetProcessHeap(), 0, object
);
5895 *compiler
= &object
->ID3DXEffectCompiler_iface
;
5897 TRACE("Created ID3DXEffectCompiler %p\n", object
);
5902 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl
;
5904 struct ID3DXEffectPoolImpl
5906 ID3DXEffectPool ID3DXEffectPool_iface
;
5910 static inline struct ID3DXEffectPoolImpl
*impl_from_ID3DXEffectPool(ID3DXEffectPool
*iface
)
5912 return CONTAINING_RECORD(iface
, struct ID3DXEffectPoolImpl
, ID3DXEffectPool_iface
);
5915 /*** IUnknown methods ***/
5916 static HRESULT WINAPI
ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool
*iface
, REFIID riid
, void **object
)
5918 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), object
);
5920 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
5921 IsEqualGUID(riid
, &IID_ID3DXEffectPool
))
5923 iface
->lpVtbl
->AddRef(iface
);
5928 WARN("Interface %s not found\n", debugstr_guid(riid
));
5930 return E_NOINTERFACE
;
5933 static ULONG WINAPI
ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool
*iface
)
5935 struct ID3DXEffectPoolImpl
*This
= impl_from_ID3DXEffectPool(iface
);
5937 TRACE("(%p)->(): AddRef from %u\n", This
, This
->ref
);
5939 return InterlockedIncrement(&This
->ref
);
5942 static ULONG WINAPI
ID3DXEffectPoolImpl_Release(ID3DXEffectPool
*iface
)
5944 struct ID3DXEffectPoolImpl
*This
= impl_from_ID3DXEffectPool(iface
);
5945 ULONG ref
= InterlockedDecrement(&This
->ref
);
5947 TRACE("(%p)->(): Release from %u\n", This
, ref
+ 1);
5950 HeapFree(GetProcessHeap(), 0, This
);
5955 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl
=
5957 /*** IUnknown methods ***/
5958 ID3DXEffectPoolImpl_QueryInterface
,
5959 ID3DXEffectPoolImpl_AddRef
,
5960 ID3DXEffectPoolImpl_Release
5963 HRESULT WINAPI
D3DXCreateEffectPool(LPD3DXEFFECTPOOL
*pool
)
5965 struct ID3DXEffectPoolImpl
*object
;
5967 TRACE("(%p)\n", pool
);
5970 return D3DERR_INVALIDCALL
;
5972 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
5975 ERR("Out of memory\n");
5976 return E_OUTOFMEMORY
;
5979 object
->ID3DXEffectPool_iface
.lpVtbl
= &ID3DXEffectPool_Vtbl
;
5982 *pool
= &object
->ID3DXEffectPool_iface
;
5987 HRESULT WINAPI
D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device
, LPCWSTR srcfile
,
5988 const D3DXMACRO
*defines
, LPD3DXINCLUDE include
, LPCSTR skipconstants
, DWORD flags
,
5989 LPD3DXEFFECTPOOL pool
, LPD3DXEFFECT
*effect
, LPD3DXBUFFER
*compilationerrors
)
5995 TRACE("(%s): relay\n", debugstr_w(srcfile
));
5997 if (!device
|| !srcfile
)
5998 return D3DERR_INVALIDCALL
;
6000 ret
= map_view_of_file(srcfile
, &buffer
, &size
);
6003 return D3DXERR_INVALIDDATA
;
6005 ret
= D3DXCreateEffectEx(device
, buffer
, size
, defines
, include
, skipconstants
, flags
, pool
, effect
, compilationerrors
);
6006 UnmapViewOfFile(buffer
);
6011 HRESULT WINAPI
D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device
, LPCSTR srcfile
,
6012 const D3DXMACRO
*defines
, LPD3DXINCLUDE include
, LPCSTR skipconstants
, DWORD flags
,
6013 LPD3DXEFFECTPOOL pool
, LPD3DXEFFECT
*effect
, LPD3DXBUFFER
*compilationerrors
)
6019 TRACE("(void): relay\n");
6022 return D3DERR_INVALIDCALL
;
6024 len
= MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, NULL
, 0);
6025 srcfileW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(*srcfileW
));
6026 MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, srcfileW
, len
);
6028 ret
= D3DXCreateEffectFromFileExW(device
, srcfileW
, defines
, include
, skipconstants
, flags
, pool
, effect
, compilationerrors
);
6029 HeapFree(GetProcessHeap(), 0, srcfileW
);
6034 HRESULT WINAPI
D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device
, LPCWSTR srcfile
,
6035 const D3DXMACRO
*defines
, LPD3DXINCLUDE include
, DWORD flags
, LPD3DXEFFECTPOOL pool
,
6036 LPD3DXEFFECT
*effect
, LPD3DXBUFFER
*compilationerrors
)
6038 TRACE("(void): relay\n");
6039 return D3DXCreateEffectFromFileExW(device
, srcfile
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
6042 HRESULT WINAPI
D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device
, LPCSTR srcfile
,
6043 const D3DXMACRO
*defines
, LPD3DXINCLUDE include
, DWORD flags
, LPD3DXEFFECTPOOL pool
,
6044 LPD3DXEFFECT
*effect
, LPD3DXBUFFER
*compilationerrors
)
6046 TRACE("(void): relay\n");
6047 return D3DXCreateEffectFromFileExA(device
, srcfile
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
6050 HRESULT WINAPI
D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device
, HMODULE srcmodule
, LPCWSTR srcresource
,
6051 const D3DXMACRO
*defines
, LPD3DXINCLUDE include
, LPCSTR skipconstants
, DWORD flags
,
6052 LPD3DXEFFECTPOOL pool
, LPD3DXEFFECT
*effect
, LPD3DXBUFFER
*compilationerrors
)
6056 TRACE("(%p, %s): relay\n", srcmodule
, debugstr_w(srcresource
));
6059 return D3DERR_INVALIDCALL
;
6061 resinfo
= FindResourceW(srcmodule
, srcresource
, (LPCWSTR
) RT_RCDATA
);
6069 ret
= load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
);
6072 return D3DXERR_INVALIDDATA
;
6074 return D3DXCreateEffectEx(device
, buffer
, size
, defines
, include
, skipconstants
, flags
, pool
, effect
, compilationerrors
);
6077 return D3DXERR_INVALIDDATA
;
6080 HRESULT WINAPI
D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device
, HMODULE srcmodule
, LPCSTR srcresource
,
6081 const D3DXMACRO
*defines
, LPD3DXINCLUDE include
, LPCSTR skipconstants
, DWORD flags
,
6082 LPD3DXEFFECTPOOL pool
, LPD3DXEFFECT
*effect
, LPD3DXBUFFER
*compilationerrors
)
6086 TRACE("(%p, %s): relay\n", srcmodule
, debugstr_a(srcresource
));
6089 return D3DERR_INVALIDCALL
;
6091 resinfo
= FindResourceA(srcmodule
, srcresource
, (LPCSTR
) RT_RCDATA
);
6099 ret
= load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
);
6102 return D3DXERR_INVALIDDATA
;
6104 return D3DXCreateEffectEx(device
, buffer
, size
, defines
, include
, skipconstants
, flags
, pool
, effect
, compilationerrors
);
6107 return D3DXERR_INVALIDDATA
;
6110 HRESULT WINAPI
D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device
, HMODULE srcmodule
, LPCWSTR srcresource
,
6111 const D3DXMACRO
*defines
, LPD3DXINCLUDE include
, DWORD flags
, LPD3DXEFFECTPOOL pool
,
6112 LPD3DXEFFECT
*effect
, LPD3DXBUFFER
*compilationerrors
)
6114 TRACE("(void): relay\n");
6115 return D3DXCreateEffectFromResourceExW(device
, srcmodule
, srcresource
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
6118 HRESULT WINAPI
D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device
, HMODULE srcmodule
, LPCSTR srcresource
,
6119 const D3DXMACRO
*defines
, LPD3DXINCLUDE include
, DWORD flags
, LPD3DXEFFECTPOOL pool
,
6120 LPD3DXEFFECT
*effect
, LPD3DXBUFFER
*compilationerrors
)
6122 TRACE("(void): relay\n");
6123 return D3DXCreateEffectFromResourceExA(device
, srcmodule
, srcresource
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
6126 HRESULT WINAPI
D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile
, const D3DXMACRO
*defines
, LPD3DXINCLUDE include
,
6127 DWORD flags
, LPD3DXEFFECTCOMPILER
*effectcompiler
, LPD3DXBUFFER
*parseerrors
)
6133 TRACE("(%s): relay\n", debugstr_w(srcfile
));
6136 return D3DERR_INVALIDCALL
;
6138 ret
= map_view_of_file(srcfile
, &buffer
, &size
);
6141 return D3DXERR_INVALIDDATA
;
6143 ret
= D3DXCreateEffectCompiler(buffer
, size
, defines
, include
, flags
, effectcompiler
, parseerrors
);
6144 UnmapViewOfFile(buffer
);
6149 HRESULT WINAPI
D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile
, const D3DXMACRO
*defines
, LPD3DXINCLUDE include
,
6150 DWORD flags
, LPD3DXEFFECTCOMPILER
*effectcompiler
, LPD3DXBUFFER
*parseerrors
)
6156 TRACE("(void): relay\n");
6159 return D3DERR_INVALIDCALL
;
6161 len
= MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, NULL
, 0);
6162 srcfileW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(*srcfileW
));
6163 MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, srcfileW
, len
);
6165 ret
= D3DXCreateEffectCompilerFromFileW(srcfileW
, defines
, include
, flags
, effectcompiler
, parseerrors
);
6166 HeapFree(GetProcessHeap(), 0, srcfileW
);
6171 HRESULT WINAPI
D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule
, LPCSTR srcresource
, const D3DXMACRO
*defines
,
6172 LPD3DXINCLUDE include
, DWORD flags
, LPD3DXEFFECTCOMPILER
*effectcompiler
, LPD3DXBUFFER
*parseerrors
)
6176 TRACE("(%p, %s): relay\n", srcmodule
, debugstr_a(srcresource
));
6178 resinfo
= FindResourceA(srcmodule
, srcresource
, (LPCSTR
) RT_RCDATA
);
6186 ret
= load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
);
6189 return D3DXERR_INVALIDDATA
;
6191 return D3DXCreateEffectCompiler(buffer
, size
, defines
, include
, flags
, effectcompiler
, parseerrors
);
6194 return D3DXERR_INVALIDDATA
;
6197 HRESULT WINAPI
D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule
, LPCWSTR srcresource
, const D3DXMACRO
*defines
,
6198 LPD3DXINCLUDE include
, DWORD flags
, LPD3DXEFFECTCOMPILER
*effectcompiler
, LPD3DXBUFFER
*parseerrors
)
6202 TRACE("(%p, %s): relay\n", srcmodule
, debugstr_w(srcresource
));
6204 resinfo
= FindResourceW(srcmodule
, srcresource
, (LPCWSTR
) RT_RCDATA
);
6212 ret
= load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
);
6215 return D3DXERR_INVALIDDATA
;
6217 return D3DXCreateEffectCompiler(buffer
, size
, defines
, include
, flags
, effectcompiler
, parseerrors
);
6220 return D3DXERR_INVALIDDATA
;