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"
29 #include "d3dcompiler.h"
31 /* Constants for special INT/FLOAT conversation */
32 #define INT_FLOAT_MULTI 255.0f
33 #define INT_FLOAT_MULTI_INVERSE (1/INT_FLOAT_MULTI)
35 #define INITIAL_PARAM_TABLE_SIZE 16
37 WINE_DEFAULT_DEBUG_CHANNEL(d3dx
);
84 enum SHADER_CONSTANT_TYPE
102 struct d3dx_parameter
107 D3DXPARAMETER_CLASS
class;
108 D3DXPARAMETER_TYPE type
;
112 UINT annotation_count
;
120 struct d3dx_parameter
*annotations
;
121 struct d3dx_parameter
*members
;
123 struct d3dx_parameter
*referenced_param
;
130 struct d3dx_parameter
*param
;
137 enum STATE_TYPE type
;
138 struct d3dx_parameter parameter
;
144 struct d3dx_state
*states
;
151 UINT annotation_count
;
153 struct d3dx_state
*states
;
154 struct d3dx_parameter
*annotations
;
157 struct d3dx_technique
161 UINT annotation_count
;
163 struct d3dx_parameter
*annotations
;
164 struct d3dx_pass
*passes
;
169 struct d3dx_parameter
**table
;
170 unsigned int count
, size
;
173 struct d3dx9_base_effect
175 struct ID3DXEffectImpl
*effect
;
177 UINT parameter_count
;
178 UINT technique_count
;
181 struct d3dx_parameter
*parameters
;
182 struct d3dx_technique
*techniques
;
183 struct d3dx_object
*objects
;
185 struct param_table param_table
;
188 struct ID3DXEffectImpl
190 ID3DXEffect ID3DXEffect_iface
;
193 struct d3dx9_base_effect base_effect
;
195 struct ID3DXEffectStateManager
*manager
;
196 struct IDirect3DDevice9
*device
;
197 struct ID3DXEffectPool
*pool
;
198 struct d3dx_technique
*active_technique
;
199 struct d3dx_pass
*active_pass
;
204 struct ID3DXEffectCompilerImpl
206 ID3DXEffectCompiler ID3DXEffectCompiler_iface
;
209 struct d3dx9_base_effect base_effect
;
212 static struct d3dx_parameter
*get_parameter_by_name(struct d3dx9_base_effect
*base
,
213 struct d3dx_parameter
*parameter
, const char *name
);
214 static struct d3dx_parameter
*get_annotation_by_name(UINT count
, struct d3dx_parameter
*parameters
,
216 static HRESULT
d3dx9_parse_state(struct d3dx9_base_effect
*base
, struct d3dx_state
*state
,
217 const char *data
, const char **ptr
, struct d3dx_object
*objects
);
218 static void free_parameter(struct d3dx_parameter
*param
, BOOL element
, BOOL child
);
222 enum STATE_CLASS
class;
229 {SC_RENDERSTATE
, D3DRS_ZENABLE
, "D3DRS_ZENABLE"}, /* 0x0 */
230 {SC_RENDERSTATE
, D3DRS_FILLMODE
, "D3DRS_FILLMODE"},
231 {SC_RENDERSTATE
, D3DRS_SHADEMODE
, "D3DRS_SHADEMODE"},
232 {SC_RENDERSTATE
, D3DRS_ZWRITEENABLE
, "D3DRS_ZWRITEENABLE"},
233 {SC_RENDERSTATE
, D3DRS_ALPHATESTENABLE
, "D3DRS_ALPHATESTENABLE"},
234 {SC_RENDERSTATE
, D3DRS_LASTPIXEL
, "D3DRS_LASTPIXEL"},
235 {SC_RENDERSTATE
, D3DRS_SRCBLEND
, "D3DRS_SRCBLEND"},
236 {SC_RENDERSTATE
, D3DRS_DESTBLEND
, "D3DRS_DESTBLEND"},
237 {SC_RENDERSTATE
, D3DRS_CULLMODE
, "D3DRS_CULLMODE"},
238 {SC_RENDERSTATE
, D3DRS_ZFUNC
, "D3DRS_ZFUNC"},
239 {SC_RENDERSTATE
, D3DRS_ALPHAREF
, "D3DRS_ALPHAREF"},
240 {SC_RENDERSTATE
, D3DRS_ALPHAFUNC
, "D3DRS_ALPHAFUNC"},
241 {SC_RENDERSTATE
, D3DRS_DITHERENABLE
, "D3DRS_DITHERENABLE"},
242 {SC_RENDERSTATE
, D3DRS_ALPHABLENDENABLE
, "D3DRS_ALPHABLENDENABLE"},
243 {SC_RENDERSTATE
, D3DRS_FOGENABLE
, "D3DRS_FOGENABLE"},
244 {SC_RENDERSTATE
, D3DRS_SPECULARENABLE
, "D3DRS_SPECULARENABLE"},
245 {SC_RENDERSTATE
, D3DRS_FOGCOLOR
, "D3DRS_FOGCOLOR"}, /* 0x10 */
246 {SC_RENDERSTATE
, D3DRS_FOGTABLEMODE
, "D3DRS_FOGTABLEMODE"},
247 {SC_RENDERSTATE
, D3DRS_FOGSTART
, "D3DRS_FOGSTART"},
248 {SC_RENDERSTATE
, D3DRS_FOGEND
, "D3DRS_FOGEND"},
249 {SC_RENDERSTATE
, D3DRS_FOGDENSITY
, "D3DRS_FOGDENSITY"},
250 {SC_RENDERSTATE
, D3DRS_RANGEFOGENABLE
, "D3DRS_RANGEFOGENABLE"},
251 {SC_RENDERSTATE
, D3DRS_STENCILENABLE
, "D3DRS_STENCILENABLE"},
252 {SC_RENDERSTATE
, D3DRS_STENCILFAIL
, "D3DRS_STENCILFAIL"},
253 {SC_RENDERSTATE
, D3DRS_STENCILZFAIL
, "D3DRS_STENCILZFAIL"},
254 {SC_RENDERSTATE
, D3DRS_STENCILPASS
, "D3DRS_STENCILPASS"},
255 {SC_RENDERSTATE
, D3DRS_STENCILFUNC
, "D3DRS_STENCILFUNC"},
256 {SC_RENDERSTATE
, D3DRS_STENCILREF
, "D3DRS_STENCILREF"},
257 {SC_RENDERSTATE
, D3DRS_STENCILMASK
, "D3DRS_STENCILMASK"},
258 {SC_RENDERSTATE
, D3DRS_STENCILWRITEMASK
, "D3DRS_STENCILWRITEMASK"},
259 {SC_RENDERSTATE
, D3DRS_TEXTUREFACTOR
, "D3DRS_TEXTUREFACTOR"},
260 {SC_RENDERSTATE
, D3DRS_WRAP0
, "D3DRS_WRAP0"},
261 {SC_RENDERSTATE
, D3DRS_WRAP1
, "D3DRS_WRAP1"}, /* 0x20 */
262 {SC_RENDERSTATE
, D3DRS_WRAP2
, "D3DRS_WRAP2"},
263 {SC_RENDERSTATE
, D3DRS_WRAP3
, "D3DRS_WRAP3"},
264 {SC_RENDERSTATE
, D3DRS_WRAP4
, "D3DRS_WRAP4"},
265 {SC_RENDERSTATE
, D3DRS_WRAP5
, "D3DRS_WRAP5"},
266 {SC_RENDERSTATE
, D3DRS_WRAP6
, "D3DRS_WRAP6"},
267 {SC_RENDERSTATE
, D3DRS_WRAP7
, "D3DRS_WRAP7"},
268 {SC_RENDERSTATE
, D3DRS_WRAP8
, "D3DRS_WRAP8"},
269 {SC_RENDERSTATE
, D3DRS_WRAP9
, "D3DRS_WRAP9"},
270 {SC_RENDERSTATE
, D3DRS_WRAP10
, "D3DRS_WRAP10"},
271 {SC_RENDERSTATE
, D3DRS_WRAP11
, "D3DRS_WRAP11"},
272 {SC_RENDERSTATE
, D3DRS_WRAP12
, "D3DRS_WRAP12"},
273 {SC_RENDERSTATE
, D3DRS_WRAP13
, "D3DRS_WRAP13"},
274 {SC_RENDERSTATE
, D3DRS_WRAP14
, "D3DRS_WRAP14"},
275 {SC_RENDERSTATE
, D3DRS_WRAP15
, "D3DRS_WRAP15"},
276 {SC_RENDERSTATE
, D3DRS_CLIPPING
, "D3DRS_CLIPPING"},
277 {SC_RENDERSTATE
, D3DRS_LIGHTING
, "D3DRS_LIGHTING"}, /* 0x30 */
278 {SC_RENDERSTATE
, D3DRS_AMBIENT
, "D3DRS_AMBIENT"},
279 {SC_RENDERSTATE
, D3DRS_FOGVERTEXMODE
, "D3DRS_FOGVERTEXMODE"},
280 {SC_RENDERSTATE
, D3DRS_COLORVERTEX
, "D3DRS_COLORVERTEX"},
281 {SC_RENDERSTATE
, D3DRS_LOCALVIEWER
, "D3DRS_LOCALVIEWER"},
282 {SC_RENDERSTATE
, D3DRS_NORMALIZENORMALS
, "D3DRS_NORMALIZENORMALS"},
283 {SC_RENDERSTATE
, D3DRS_DIFFUSEMATERIALSOURCE
, "D3DRS_DIFFUSEMATERIALSOURCE"},
284 {SC_RENDERSTATE
, D3DRS_SPECULARMATERIALSOURCE
, "D3DRS_SPECULARMATERIALSOURCE"},
285 {SC_RENDERSTATE
, D3DRS_AMBIENTMATERIALSOURCE
, "D3DRS_AMBIENTMATERIALSOURCE"},
286 {SC_RENDERSTATE
, D3DRS_EMISSIVEMATERIALSOURCE
, "D3DRS_EMISSIVEMATERIALSOURCE"},
287 {SC_RENDERSTATE
, D3DRS_VERTEXBLEND
, "D3DRS_VERTEXBLEND"},
288 {SC_RENDERSTATE
, D3DRS_CLIPPLANEENABLE
, "D3DRS_CLIPPLANEENABLE"},
289 {SC_RENDERSTATE
, D3DRS_POINTSIZE
, "D3DRS_POINTSIZE"},
290 {SC_RENDERSTATE
, D3DRS_POINTSIZE_MIN
, "D3DRS_POINTSIZE_MIN"},
291 {SC_RENDERSTATE
, D3DRS_POINTSIZE_MAX
, "D3DRS_POINTSIZE_MAX"},
292 {SC_RENDERSTATE
, D3DRS_POINTSPRITEENABLE
, "D3DRS_POINTSPRITEENABLE"},
293 {SC_RENDERSTATE
, D3DRS_POINTSCALEENABLE
, "D3DRS_POINTSCALEENABLE"}, /* 0x40 */
294 {SC_RENDERSTATE
, D3DRS_POINTSCALE_A
, "D3DRS_POINTSCALE_A"},
295 {SC_RENDERSTATE
, D3DRS_POINTSCALE_B
, "D3DRS_POINTSCALE_B"},
296 {SC_RENDERSTATE
, D3DRS_POINTSCALE_C
, "D3DRS_POINTSCALE_C"},
297 {SC_RENDERSTATE
, D3DRS_MULTISAMPLEANTIALIAS
, "D3DRS_MULTISAMPLEANTIALIAS"},
298 {SC_RENDERSTATE
, D3DRS_MULTISAMPLEMASK
, "D3DRS_MULTISAMPLEMASK"},
299 {SC_RENDERSTATE
, D3DRS_PATCHEDGESTYLE
, "D3DRS_PATCHEDGESTYLE"},
300 {SC_RENDERSTATE
, D3DRS_DEBUGMONITORTOKEN
, "D3DRS_DEBUGMONITORTOKEN"},
301 {SC_RENDERSTATE
, D3DRS_INDEXEDVERTEXBLENDENABLE
, "D3DRS_INDEXEDVERTEXBLENDENABLE"},
302 {SC_RENDERSTATE
, D3DRS_COLORWRITEENABLE
, "D3DRS_COLORWRITEENABLE"},
303 {SC_RENDERSTATE
, D3DRS_TWEENFACTOR
, "D3DRS_TWEENFACTOR"},
304 {SC_RENDERSTATE
, D3DRS_BLENDOP
, "D3DRS_BLENDOP"},
305 {SC_RENDERSTATE
, D3DRS_POSITIONDEGREE
, "D3DRS_POSITIONDEGREE"},
306 {SC_RENDERSTATE
, D3DRS_NORMALDEGREE
, "D3DRS_NORMALDEGREE"},
307 {SC_RENDERSTATE
, D3DRS_SCISSORTESTENABLE
, "D3DRS_SCISSORTESTENABLE"},
308 {SC_RENDERSTATE
, D3DRS_SLOPESCALEDEPTHBIAS
, "D3DRS_SLOPESCALEDEPTHBIAS"},
309 {SC_RENDERSTATE
, D3DRS_ANTIALIASEDLINEENABLE
, "D3DRS_ANTIALIASEDLINEENABLE"}, /* 0x50 */
310 {SC_RENDERSTATE
, D3DRS_MINTESSELLATIONLEVEL
, "D3DRS_MINTESSELLATIONLEVEL"},
311 {SC_RENDERSTATE
, D3DRS_MAXTESSELLATIONLEVEL
, "D3DRS_MAXTESSELLATIONLEVEL"},
312 {SC_RENDERSTATE
, D3DRS_ADAPTIVETESS_X
, "D3DRS_ADAPTIVETESS_X"},
313 {SC_RENDERSTATE
, D3DRS_ADAPTIVETESS_Y
, "D3DRS_ADAPTIVETESS_Y"},
314 {SC_RENDERSTATE
, D3DRS_ADAPTIVETESS_Z
, "D3DRS_ADAPTIVETESS_Z"},
315 {SC_RENDERSTATE
, D3DRS_ADAPTIVETESS_W
, "D3DRS_ADAPTIVETESS_W"},
316 {SC_RENDERSTATE
, D3DRS_ENABLEADAPTIVETESSELLATION
, "D3DRS_ENABLEADAPTIVETESSELLATION"},
317 {SC_RENDERSTATE
, D3DRS_TWOSIDEDSTENCILMODE
, "D3DRS_TWOSIDEDSTENCILMODE"},
318 {SC_RENDERSTATE
, D3DRS_CCW_STENCILFAIL
, "D3DRS_CCW_STENCILFAIL"},
319 {SC_RENDERSTATE
, D3DRS_CCW_STENCILZFAIL
, "D3DRS_CCW_STENCILZFAIL"},
320 {SC_RENDERSTATE
, D3DRS_CCW_STENCILPASS
, "D3DRS_CCW_STENCILPASS"},
321 {SC_RENDERSTATE
, D3DRS_CCW_STENCILFUNC
, "D3DRS_CCW_STENCILFUNC"},
322 {SC_RENDERSTATE
, D3DRS_COLORWRITEENABLE1
, "D3DRS_COLORWRITEENABLE1"},
323 {SC_RENDERSTATE
, D3DRS_COLORWRITEENABLE2
, "D3DRS_COLORWRITEENABLE2"},
324 {SC_RENDERSTATE
, D3DRS_COLORWRITEENABLE3
, "D3DRS_COLORWRITEENABLE3"},
325 {SC_RENDERSTATE
, D3DRS_BLENDFACTOR
, "D3DRS_BLENDFACTOR"}, /* 0x60 */
326 {SC_RENDERSTATE
, D3DRS_SRGBWRITEENABLE
, "D3DRS_SRGBWRITEENABLE"},
327 {SC_RENDERSTATE
, D3DRS_DEPTHBIAS
, "D3DRS_DEPTHBIAS"},
328 {SC_RENDERSTATE
, D3DRS_SEPARATEALPHABLENDENABLE
, "D3DRS_SEPARATEALPHABLENDENABLE"},
329 {SC_RENDERSTATE
, D3DRS_SRCBLENDALPHA
, "D3DRS_SRCBLENDALPHA"},
330 {SC_RENDERSTATE
, D3DRS_DESTBLENDALPHA
, "D3DRS_DESTBLENDALPHA"},
331 {SC_RENDERSTATE
, D3DRS_BLENDOPALPHA
, "D3DRS_BLENDOPALPHA"},
333 {SC_TEXTURESTAGE
, D3DTSS_COLOROP
, "D3DTSS_COLOROP"},
334 {SC_TEXTURESTAGE
, D3DTSS_COLORARG0
, "D3DTSS_COLORARG0"},
335 {SC_TEXTURESTAGE
, D3DTSS_COLORARG1
, "D3DTSS_COLORARG1"},
336 {SC_TEXTURESTAGE
, D3DTSS_COLORARG2
, "D3DTSS_COLORARG2"},
337 {SC_TEXTURESTAGE
, D3DTSS_ALPHAOP
, "D3DTSS_ALPHAOP"},
338 {SC_TEXTURESTAGE
, D3DTSS_ALPHAARG0
, "D3DTSS_ALPHAARG0"},
339 {SC_TEXTURESTAGE
, D3DTSS_ALPHAARG1
, "D3DTSS_ALPHAARG1"},
340 {SC_TEXTURESTAGE
, D3DTSS_ALPHAARG2
, "D3DTSS_ALPHAARG2"},
341 {SC_TEXTURESTAGE
, D3DTSS_RESULTARG
, "D3DTSS_RESULTARG"},
342 {SC_TEXTURESTAGE
, D3DTSS_BUMPENVMAT00
, "D3DTSS_BUMPENVMAT00"}, /* 0x70 */
343 {SC_TEXTURESTAGE
, D3DTSS_BUMPENVMAT01
, "D3DTSS_BUMPENVMAT01"},
344 {SC_TEXTURESTAGE
, D3DTSS_BUMPENVMAT10
, "D3DTSS_BUMPENVMAT10"},
345 {SC_TEXTURESTAGE
, D3DTSS_BUMPENVMAT11
, "D3DTSS_BUMPENVMAT11"},
346 {SC_TEXTURESTAGE
, D3DTSS_TEXCOORDINDEX
, "D3DTSS_TEXCOORDINDEX"},
347 {SC_TEXTURESTAGE
, D3DTSS_BUMPENVLSCALE
, "D3DTSS_BUMPENVLSCALE"},
348 {SC_TEXTURESTAGE
, D3DTSS_BUMPENVLOFFSET
, "D3DTSS_BUMPENVLOFFSET"},
349 {SC_TEXTURESTAGE
, D3DTSS_TEXTURETRANSFORMFLAGS
, "D3DTSS_TEXTURETRANSFORMFLAGS"},
350 {SC_TEXTURESTAGE
, D3DTSS_CONSTANT
, "D3DTSS_CONSTANT"},
352 {SC_NPATCHMODE
, 0, "NPatchMode"},
356 {SC_TRANSFORM
, D3DTS_PROJECTION
, "D3DTS_PROJECTION"},
357 {SC_TRANSFORM
, D3DTS_VIEW
, "D3DTS_VIEW"},
358 {SC_TRANSFORM
, D3DTS_WORLD
, "D3DTS_WORLD"},
359 {SC_TRANSFORM
, D3DTS_TEXTURE0
, "D3DTS_TEXTURE0"},
361 {SC_MATERIAL
, MT_DIFFUSE
, "MaterialDiffuse"},
362 {SC_MATERIAL
, MT_AMBIENT
, "MaterialAmbient"}, /* 0x80 */
363 {SC_MATERIAL
, MT_SPECULAR
, "MaterialSpecular"},
364 {SC_MATERIAL
, MT_EMISSIVE
, "MaterialEmissive"},
365 {SC_MATERIAL
, MT_POWER
, "MaterialPower"},
367 {SC_LIGHT
, LT_TYPE
, "LightType"},
368 {SC_LIGHT
, LT_DIFFUSE
, "LightDiffuse"},
369 {SC_LIGHT
, LT_SPECULAR
, "LightSpecular"},
370 {SC_LIGHT
, LT_AMBIENT
, "LightAmbient"},
371 {SC_LIGHT
, LT_POSITION
, "LightPosition"},
372 {SC_LIGHT
, LT_DIRECTION
, "LightDirection"},
373 {SC_LIGHT
, LT_RANGE
, "LightRange"},
374 {SC_LIGHT
, LT_FALLOFF
, "LightFallOff"},
375 {SC_LIGHT
, LT_ATTENUATION0
, "LightAttenuation0"},
376 {SC_LIGHT
, LT_ATTENUATION1
, "LightAttenuation1"},
377 {SC_LIGHT
, LT_ATTENUATION2
, "LightAttenuation2"},
378 {SC_LIGHT
, LT_THETA
, "LightTheta"},
379 {SC_LIGHT
, LT_PHI
, "LightPhi"}, /* 0x90 */
381 {SC_LIGHTENABLE
, 0, "LightEnable"},
383 {SC_VERTEXSHADER
, 0, "Vertexshader"},
385 {SC_PIXELSHADER
, 0, "Pixelshader"},
386 /* Shader constants */
387 {SC_SHADERCONST
, SCT_VSFLOAT
, "VertexShaderConstantF"},
388 {SC_SHADERCONST
, SCT_VSBOOL
, "VertexShaderConstantB"},
389 {SC_SHADERCONST
, SCT_VSINT
, "VertexShaderConstantI"},
390 {SC_SHADERCONST
, SCT_VSFLOAT
, "VertexShaderConstant"},
391 {SC_SHADERCONST
, SCT_VSFLOAT
, "VertexShaderConstant1"},
392 {SC_SHADERCONST
, SCT_VSFLOAT
, "VertexShaderConstant2"},
393 {SC_SHADERCONST
, SCT_VSFLOAT
, "VertexShaderConstant3"},
394 {SC_SHADERCONST
, SCT_VSFLOAT
, "VertexShaderConstant4"},
395 {SC_SHADERCONST
, SCT_PSFLOAT
, "PixelShaderConstantF"},
396 {SC_SHADERCONST
, SCT_PSBOOL
, "PixelShaderConstantB"},
397 {SC_SHADERCONST
, SCT_PSINT
, "PixelShaderConstantI"},
398 {SC_SHADERCONST
, SCT_PSFLOAT
, "PixelShaderConstant"},
399 {SC_SHADERCONST
, SCT_PSFLOAT
, "PixelShaderConstant1"}, /* 0xa0 */
400 {SC_SHADERCONST
, SCT_PSFLOAT
, "PixelShaderConstant2"},
401 {SC_SHADERCONST
, SCT_PSFLOAT
, "PixelShaderConstant3"},
402 {SC_SHADERCONST
, SCT_PSFLOAT
, "PixelShaderConstant4"},
404 {SC_TEXTURE
, 0, "Texture"},
406 {SC_SAMPLERSTATE
, D3DSAMP_ADDRESSU
, "AddressU"},
407 {SC_SAMPLERSTATE
, D3DSAMP_ADDRESSV
, "AddressV"},
408 {SC_SAMPLERSTATE
, D3DSAMP_ADDRESSW
, "AddressW"},
409 {SC_SAMPLERSTATE
, D3DSAMP_BORDERCOLOR
, "BorderColor"},
410 {SC_SAMPLERSTATE
, D3DSAMP_MAGFILTER
, "MagFilter"},
411 {SC_SAMPLERSTATE
, D3DSAMP_MINFILTER
, "MinFilter"},
412 {SC_SAMPLERSTATE
, D3DSAMP_MIPFILTER
, "MipFilter"},
413 {SC_SAMPLERSTATE
, D3DSAMP_MIPMAPLODBIAS
, "MipMapLodBias"},
414 {SC_SAMPLERSTATE
, D3DSAMP_MAXMIPLEVEL
, "MaxMipLevel"},
415 {SC_SAMPLERSTATE
, D3DSAMP_MAXANISOTROPY
, "MaxAnisotropy"},
416 {SC_SAMPLERSTATE
, D3DSAMP_SRGBTEXTURE
, "SRGBTexture"},
417 {SC_SAMPLERSTATE
, D3DSAMP_ELEMENTINDEX
, "ElementIndex"}, /* 0xb0 */
418 {SC_SAMPLERSTATE
, D3DSAMP_DMAPOFFSET
, "DMAPOffset"},
420 {SC_SETSAMPLER
, 0, "Sampler"},
423 static inline void read_dword(const char **ptr
, DWORD
*d
)
425 memcpy(d
, *ptr
, sizeof(*d
));
429 static void skip_dword_unknown(const char **ptr
, unsigned int count
)
434 FIXME("Skipping %u unknown DWORDs:\n", count
);
435 for (i
= 0; i
< count
; ++i
)
438 FIXME("\t0x%08x\n", d
);
442 static inline D3DXHANDLE
get_parameter_handle(struct d3dx_parameter
*parameter
)
444 return parameter
? parameter
->handle
: NULL
;
447 static inline D3DXHANDLE
get_technique_handle(struct d3dx_technique
*technique
)
449 return (D3DXHANDLE
) technique
;
452 static inline D3DXHANDLE
get_pass_handle(struct d3dx_pass
*pass
)
454 return (D3DXHANDLE
) pass
;
457 static struct d3dx_technique
*get_technique_by_name(struct d3dx9_base_effect
*base
, const char *name
)
461 if (!name
) return NULL
;
463 for (i
= 0; i
< base
->technique_count
; ++i
)
465 if (!strcmp(base
->techniques
[i
].name
, name
))
466 return &base
->techniques
[i
];
472 static struct d3dx_technique
*get_valid_technique(struct d3dx9_base_effect
*base
, D3DXHANDLE technique
)
476 for (i
= 0; i
< base
->technique_count
; ++i
)
478 if (get_technique_handle(&base
->techniques
[i
]) == technique
)
479 return &base
->techniques
[i
];
482 return get_technique_by_name(base
, technique
);
485 static struct d3dx_pass
*get_valid_pass(struct d3dx9_base_effect
*base
, D3DXHANDLE pass
)
489 for (i
= 0; i
< base
->technique_count
; ++i
)
491 struct d3dx_technique
*technique
= &base
->techniques
[i
];
493 for (k
= 0; k
< technique
->pass_count
; ++k
)
495 if (get_pass_handle(&technique
->passes
[k
]) == pass
)
496 return &technique
->passes
[k
];
503 static struct d3dx_parameter
*get_valid_parameter(struct d3dx9_base_effect
*base
, D3DXHANDLE parameter
)
505 struct d3dx_parameter
**handle_param
= (struct d3dx_parameter
**)parameter
;
507 if (handle_param
>= base
->param_table
.table
&& handle_param
< base
->param_table
.table
+ base
->param_table
.count
)
508 return *handle_param
;
510 return get_parameter_by_name(base
, NULL
, parameter
);
513 static void free_state(struct d3dx_state
*state
)
515 free_parameter(&state
->parameter
, FALSE
, FALSE
);
518 static void free_object(struct d3dx_object
*object
)
520 HeapFree(GetProcessHeap(), 0, object
->data
);
523 static void free_sampler(struct d3dx_sampler
*sampler
)
527 for (i
= 0; i
< sampler
->state_count
; ++i
)
529 free_state(&sampler
->states
[i
]);
531 HeapFree(GetProcessHeap(), 0, sampler
->states
);
534 static void free_parameter(struct d3dx_parameter
*param
, BOOL element
, BOOL child
)
538 TRACE("Free parameter %p, name %s, type %s, child %s\n", param
, param
->name
,
539 debug_d3dxparameter_type(param
->type
), child
? "yes" : "no");
544 if (param
->annotations
)
546 for (i
= 0; i
< param
->annotation_count
; ++i
)
547 free_parameter(¶m
->annotations
[i
], FALSE
, FALSE
);
548 HeapFree(GetProcessHeap(), 0, param
->annotations
);
549 param
->annotations
= NULL
;
554 unsigned int count
= param
->element_count
? param
->element_count
: param
->member_count
;
556 for (i
= 0; i
< count
; ++i
)
557 free_parameter(¶m
->members
[i
], param
->element_count
!= 0, TRUE
);
558 HeapFree(GetProcessHeap(), 0, param
->members
);
559 param
->members
= NULL
;
562 if (param
->class == D3DXPC_OBJECT
&& !param
->element_count
)
567 HeapFree(GetProcessHeap(), 0, *(char **)param
->data
);
571 case D3DXPT_TEXTURE1D
:
572 case D3DXPT_TEXTURE2D
:
573 case D3DXPT_TEXTURE3D
:
574 case D3DXPT_TEXTURECUBE
:
575 case D3DXPT_PIXELSHADER
:
576 case D3DXPT_VERTEXSHADER
:
577 if (*(IUnknown
**)param
->data
) IUnknown_Release(*(IUnknown
**)param
->data
);
581 case D3DXPT_SAMPLER1D
:
582 case D3DXPT_SAMPLER2D
:
583 case D3DXPT_SAMPLER3D
:
584 case D3DXPT_SAMPLERCUBE
:
585 free_sampler((struct d3dx_sampler
*)param
->data
);
589 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
596 HeapFree(GetProcessHeap(), 0, param
->data
);
599 /* only the parent has to release name and semantic */
602 HeapFree(GetProcessHeap(), 0, param
->name
);
603 HeapFree(GetProcessHeap(), 0, param
->semantic
);
607 static void free_pass(struct d3dx_pass
*pass
)
611 TRACE("Free pass %p\n", pass
);
616 if (pass
->annotations
)
618 for (i
= 0; i
< pass
->annotation_count
; ++i
)
619 free_parameter(&pass
->annotations
[i
], FALSE
, FALSE
);
620 HeapFree(GetProcessHeap(), 0, pass
->annotations
);
621 pass
->annotations
= NULL
;
626 for (i
= 0; i
< pass
->state_count
; ++i
)
627 free_state(&pass
->states
[i
]);
628 HeapFree(GetProcessHeap(), 0, pass
->states
);
632 HeapFree(GetProcessHeap(), 0, pass
->name
);
636 static void free_technique(struct d3dx_technique
*technique
)
640 TRACE("Free technique %p\n", technique
);
645 if (technique
->annotations
)
647 for (i
= 0; i
< technique
->annotation_count
; ++i
)
648 free_parameter(&technique
->annotations
[i
], FALSE
, FALSE
);
649 HeapFree(GetProcessHeap(), 0, technique
->annotations
);
650 technique
->annotations
= NULL
;
653 if (technique
->passes
)
655 for (i
= 0; i
< technique
->pass_count
; ++i
)
656 free_pass(&technique
->passes
[i
]);
657 HeapFree(GetProcessHeap(), 0, technique
->passes
);
658 technique
->passes
= NULL
;
661 HeapFree(GetProcessHeap(), 0, technique
->name
);
662 technique
->name
= NULL
;
665 static void d3dx9_base_effect_cleanup(struct d3dx9_base_effect
*base
)
669 TRACE("base %p.\n", base
);
671 HeapFree(GetProcessHeap(), 0, base
->param_table
.table
);
673 if (base
->parameters
)
675 for (i
= 0; i
< base
->parameter_count
; ++i
)
676 free_parameter(&base
->parameters
[i
], FALSE
, FALSE
);
677 HeapFree(GetProcessHeap(), 0, base
->parameters
);
678 base
->parameters
= NULL
;
681 if (base
->techniques
)
683 for (i
= 0; i
< base
->technique_count
; ++i
)
684 free_technique(&base
->techniques
[i
]);
685 HeapFree(GetProcessHeap(), 0, base
->techniques
);
686 base
->techniques
= NULL
;
691 for (i
= 0; i
< base
->object_count
; ++i
)
693 free_object(&base
->objects
[i
]);
695 HeapFree(GetProcessHeap(), 0, base
->objects
);
696 base
->objects
= NULL
;
700 static void free_effect(struct ID3DXEffectImpl
*effect
)
702 TRACE("Free effect %p\n", effect
);
704 d3dx9_base_effect_cleanup(&effect
->base_effect
);
708 effect
->pool
->lpVtbl
->Release(effect
->pool
);
713 IUnknown_Release(effect
->manager
);
716 IDirect3DDevice9_Release(effect
->device
);
719 static void free_effect_compiler(struct ID3DXEffectCompilerImpl
*compiler
)
721 TRACE("Free effect compiler %p\n", compiler
);
723 d3dx9_base_effect_cleanup(&compiler
->base_effect
);
726 static void get_vector(struct d3dx_parameter
*param
, D3DXVECTOR4
*vector
)
730 for (i
= 0; i
< 4; ++i
)
732 if (i
< param
->columns
)
733 set_number((FLOAT
*)vector
+ i
, D3DXPT_FLOAT
, (DWORD
*)param
->data
+ i
, param
->type
);
735 ((FLOAT
*)vector
)[i
] = 0.0f
;
739 static void set_vector(struct d3dx_parameter
*param
, const D3DXVECTOR4
*vector
)
743 for (i
= 0; i
< param
->columns
; ++i
)
745 set_number((FLOAT
*)param
->data
+ i
, param
->type
, (FLOAT
*)vector
+ i
, D3DXPT_FLOAT
);
749 static void get_matrix(struct d3dx_parameter
*param
, D3DXMATRIX
*matrix
, BOOL transpose
)
753 for (i
= 0; i
< 4; ++i
)
755 for (k
= 0; k
< 4; ++k
)
757 FLOAT
*tmp
= transpose
? (FLOAT
*)&matrix
->u
.m
[k
][i
] : (FLOAT
*)&matrix
->u
.m
[i
][k
];
759 if ((i
< param
->rows
) && (k
< param
->columns
))
760 set_number(tmp
, D3DXPT_FLOAT
, (DWORD
*)param
->data
+ i
* param
->columns
+ k
, param
->type
);
767 static void set_matrix(struct d3dx_parameter
*param
, const D3DXMATRIX
*matrix
)
771 if (param
->type
== D3DXPT_FLOAT
)
773 if (param
->columns
== 4)
774 memcpy(param
->data
, matrix
->u
.m
, param
->rows
* 4 * sizeof(float));
776 for (i
= 0; i
< param
->rows
; ++i
)
777 memcpy((float *)param
->data
+ i
* param
->columns
, matrix
->u
.m
+ i
, param
->columns
* sizeof(float));
781 for (i
= 0; i
< param
->rows
; ++i
)
783 for (k
= 0; k
< param
->columns
; ++k
)
785 set_number((FLOAT
*)param
->data
+ i
* param
->columns
+ k
, param
->type
,
786 &matrix
->u
.m
[i
][k
], D3DXPT_FLOAT
);
791 static void set_matrix_transpose(struct d3dx_parameter
*param
, const D3DXMATRIX
*matrix
)
795 for (i
= 0; i
< param
->rows
; ++i
)
797 for (k
= 0; k
< param
->columns
; ++k
)
799 set_number((FLOAT
*)param
->data
+ i
* param
->columns
+ k
, param
->type
,
800 &matrix
->u
.m
[k
][i
], D3DXPT_FLOAT
);
805 static struct d3dx_parameter
*get_parameter_element_by_name(struct d3dx_parameter
*parameter
, const char *name
)
808 struct d3dx_parameter
*temp_parameter
;
811 TRACE("parameter %p, name %s\n", parameter
, debugstr_a(name
));
813 if (!name
|| !*name
) return NULL
;
815 element
= atoi(name
);
816 part
= strchr(name
, ']') + 1;
818 /* check for empty [] && element range */
819 if ((part
- name
) > 1 && parameter
->element_count
> element
)
821 temp_parameter
= ¶meter
->members
[element
];
826 return get_parameter_by_name(NULL
, temp_parameter
, part
);
829 return get_annotation_by_name(temp_parameter
->annotation_count
, temp_parameter
->annotations
, part
);
832 TRACE("Returning parameter %p\n", temp_parameter
);
833 return temp_parameter
;
836 FIXME("Unhandled case \"%c\"\n", *--part
);
841 TRACE("Parameter not found\n");
845 static struct d3dx_parameter
*get_annotation_by_name(UINT count
, struct d3dx_parameter
*annotations
,
849 struct d3dx_parameter
*temp_parameter
;
852 TRACE("count %u, annotations %p, name %s\n", count
, annotations
, debugstr_a(name
));
854 if (!name
|| !*name
) return NULL
;
856 length
= strcspn( name
, "[.@" );
857 part
= name
+ length
;
859 for (i
= 0; i
< count
; ++i
)
861 temp_parameter
= &annotations
[i
];
863 if (!strcmp(temp_parameter
->name
, name
))
865 TRACE("Returning annotation %p\n", temp_parameter
);
866 return temp_parameter
;
868 else if (strlen(temp_parameter
->name
) == length
&& !strncmp(temp_parameter
->name
, name
, length
))
873 return get_parameter_by_name(NULL
, temp_parameter
, part
);
876 return get_parameter_element_by_name(temp_parameter
, part
);
879 FIXME("Unhandled case \"%c\"\n", *--part
);
885 TRACE("Annotation not found\n");
889 static struct d3dx_parameter
*get_parameter_by_name(struct d3dx9_base_effect
*base
,
890 struct d3dx_parameter
*parameter
, const char *name
)
892 UINT i
, count
, length
;
893 struct d3dx_parameter
*temp_parameter
;
894 struct d3dx_parameter
*parameters
;
897 TRACE("base %p, parameter %p, name %s\n", base
, parameter
, debugstr_a(name
));
899 if (!name
|| !*name
) return NULL
;
903 count
= base
->parameter_count
;
904 parameters
= base
->parameters
;
908 count
= parameter
->member_count
;
909 parameters
= parameter
->members
;
912 length
= strcspn( name
, "[.@" );
913 part
= name
+ length
;
915 for (i
= 0; i
< count
; i
++)
917 temp_parameter
= ¶meters
[i
];
919 if (!strcmp(temp_parameter
->name
, name
))
921 TRACE("Returning parameter %p\n", temp_parameter
);
922 return temp_parameter
;
924 else if (strlen(temp_parameter
->name
) == length
&& !strncmp(temp_parameter
->name
, name
, length
))
929 return get_parameter_by_name(NULL
, temp_parameter
, part
);
932 return get_annotation_by_name(temp_parameter
->annotation_count
, temp_parameter
->annotations
, part
);
935 return get_parameter_element_by_name(temp_parameter
, part
);
938 FIXME("Unhandled case \"%c\"\n", *--part
);
944 TRACE("Parameter not found\n");
948 static inline DWORD
d3dx9_effect_version(DWORD major
, DWORD minor
)
950 return (0xfeff0000 | ((major
) << 8) | (minor
));
953 static HRESULT
d3dx9_base_effect_get_desc(struct d3dx9_base_effect
*base
, D3DXEFFECT_DESC
*desc
)
957 WARN("Invalid argument specified.\n");
958 return D3DERR_INVALIDCALL
;
961 FIXME("partial stub!\n");
963 /* TODO: add creator and function count. */
964 desc
->Creator
= NULL
;
966 desc
->Parameters
= base
->parameter_count
;
967 desc
->Techniques
= base
->technique_count
;
972 static HRESULT
d3dx9_base_effect_get_parameter_desc(struct d3dx9_base_effect
*base
,
973 D3DXHANDLE parameter
, D3DXPARAMETER_DESC
*desc
)
975 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
979 WARN("Invalid argument specified.\n");
980 return D3DERR_INVALIDCALL
;
983 desc
->Name
= param
->name
;
984 desc
->Semantic
= param
->semantic
;
985 desc
->Class
= param
->class;
986 desc
->Type
= param
->type
;
987 desc
->Rows
= param
->rows
;
988 desc
->Columns
= param
->columns
;
989 desc
->Elements
= param
->element_count
;
990 desc
->Annotations
= param
->annotation_count
;
991 desc
->StructMembers
= param
->member_count
;
992 desc
->Flags
= param
->flags
;
993 desc
->Bytes
= param
->bytes
;
998 static HRESULT
d3dx9_base_effect_get_technique_desc(struct d3dx9_base_effect
*base
,
999 D3DXHANDLE technique
, D3DXTECHNIQUE_DESC
*desc
)
1001 struct d3dx_technique
*tech
= technique
? get_valid_technique(base
, technique
) : &base
->techniques
[0];
1005 WARN("Invalid argument specified.\n");
1006 return D3DERR_INVALIDCALL
;
1009 desc
->Name
= tech
->name
;
1010 desc
->Passes
= tech
->pass_count
;
1011 desc
->Annotations
= tech
->annotation_count
;
1016 static HRESULT
d3dx9_base_effect_get_pass_desc(struct d3dx9_base_effect
*base
,
1017 D3DXHANDLE pass
, D3DXPASS_DESC
*desc
)
1019 struct d3dx_pass
*p
= get_valid_pass(base
, pass
);
1023 WARN("Invalid argument specified.\n");
1024 return D3DERR_INVALIDCALL
;
1027 desc
->Name
= p
->name
;
1028 desc
->Annotations
= p
->annotation_count
;
1030 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1031 desc
->pVertexShaderFunction
= NULL
;
1032 desc
->pPixelShaderFunction
= NULL
;
1037 static HRESULT
d3dx9_base_effect_get_function_desc(struct d3dx9_base_effect
*base
,
1038 D3DXHANDLE shader
, D3DXFUNCTION_DESC
*desc
)
1045 static D3DXHANDLE
d3dx9_base_effect_get_parameter(struct d3dx9_base_effect
*base
,
1046 D3DXHANDLE parameter
, UINT index
)
1048 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1052 if (index
< base
->parameter_count
)
1054 TRACE("Returning parameter %p.\n", &base
->parameters
[index
]);
1055 return get_parameter_handle(&base
->parameters
[index
]);
1060 if (param
&& !param
->element_count
&& index
< param
->member_count
)
1062 TRACE("Returning parameter %p.\n", ¶m
->members
[index
]);
1063 return get_parameter_handle(¶m
->members
[index
]);
1067 WARN("Parameter not found.\n");
1072 static D3DXHANDLE
d3dx9_base_effect_get_parameter_by_name(struct d3dx9_base_effect
*base
,
1073 D3DXHANDLE parameter
, const char *name
)
1075 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1080 handle
= get_parameter_handle(param
);
1081 TRACE("Returning parameter %p.\n", handle
);
1085 handle
= get_parameter_handle(get_parameter_by_name(base
, param
, name
));
1086 TRACE("Returning parameter %p.\n", handle
);
1091 static D3DXHANDLE
d3dx9_base_effect_get_parameter_by_semantic(struct d3dx9_base_effect
*base
,
1092 D3DXHANDLE parameter
, const char *semantic
)
1094 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1095 struct d3dx_parameter
*temp_param
;
1100 for (i
= 0; i
< base
->parameter_count
; ++i
)
1102 temp_param
= &base
->parameters
[i
];
1104 if (!temp_param
->semantic
)
1108 TRACE("Returning parameter %p\n", temp_param
);
1109 return get_parameter_handle(temp_param
);
1114 if (!strcasecmp(temp_param
->semantic
, semantic
))
1116 TRACE("Returning parameter %p\n", temp_param
);
1117 return get_parameter_handle(temp_param
);
1123 for (i
= 0; i
< param
->member_count
; ++i
)
1125 temp_param
= ¶m
->members
[i
];
1127 if (!temp_param
->semantic
)
1131 TRACE("Returning parameter %p\n", temp_param
);
1132 return get_parameter_handle(temp_param
);
1137 if (!strcasecmp(temp_param
->semantic
, semantic
))
1139 TRACE("Returning parameter %p\n", temp_param
);
1140 return get_parameter_handle(temp_param
);
1145 WARN("Parameter not found.\n");
1150 static D3DXHANDLE
d3dx9_base_effect_get_parameter_element(struct d3dx9_base_effect
*base
,
1151 D3DXHANDLE parameter
, UINT index
)
1153 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1157 if (index
< base
->parameter_count
)
1159 TRACE("Returning parameter %p.\n", &base
->parameters
[index
]);
1160 return get_parameter_handle(&base
->parameters
[index
]);
1165 if (index
< param
->element_count
)
1167 TRACE("Returning parameter %p.\n", ¶m
->members
[index
]);
1168 return get_parameter_handle(¶m
->members
[index
]);
1172 WARN("Parameter not found.\n");
1177 static D3DXHANDLE
d3dx9_base_effect_get_technique(struct d3dx9_base_effect
*base
, UINT index
)
1179 if (index
>= base
->technique_count
)
1181 WARN("Invalid argument specified.\n");
1185 TRACE("Returning technique %p.\n", &base
->techniques
[index
]);
1187 return get_technique_handle(&base
->techniques
[index
]);
1190 static D3DXHANDLE
d3dx9_base_effect_get_technique_by_name(struct d3dx9_base_effect
*base
, const char *name
)
1192 struct d3dx_technique
*tech
= get_technique_by_name(base
, name
);
1196 D3DXHANDLE t
= get_technique_handle(tech
);
1197 TRACE("Returning technique %p\n", t
);
1201 WARN("Technique not found.\n");
1206 static D3DXHANDLE
d3dx9_base_effect_get_pass(struct d3dx9_base_effect
*base
,
1207 D3DXHANDLE technique
, UINT index
)
1209 struct d3dx_technique
*tech
= get_valid_technique(base
, technique
);
1211 if (tech
&& index
< tech
->pass_count
)
1213 TRACE("Returning pass %p\n", &tech
->passes
[index
]);
1214 return get_pass_handle(&tech
->passes
[index
]);
1217 WARN("Pass not found.\n");
1222 static D3DXHANDLE
d3dx9_base_effect_get_pass_by_name(struct d3dx9_base_effect
*base
,
1223 D3DXHANDLE technique
, const char *name
)
1225 struct d3dx_technique
*tech
= get_valid_technique(base
, technique
);
1231 for (i
= 0; i
< tech
->pass_count
; ++i
)
1233 struct d3dx_pass
*pass
= &tech
->passes
[i
];
1235 if (!strcmp(pass
->name
, name
))
1237 TRACE("Returning pass %p\n", pass
);
1238 return get_pass_handle(pass
);
1243 WARN("Pass not found.\n");
1248 static D3DXHANDLE
d3dx9_base_effect_get_function(struct d3dx9_base_effect
*base
, UINT index
)
1255 static D3DXHANDLE
d3dx9_base_effect_get_function_by_name(struct d3dx9_base_effect
*base
, const char *name
)
1262 static UINT
get_annotation_from_object(struct d3dx9_base_effect
*base
,
1263 D3DXHANDLE object
, struct d3dx_parameter
**annotations
)
1265 struct d3dx_parameter
*param
= get_valid_parameter(base
, object
);
1266 struct d3dx_pass
*pass
= get_valid_pass(base
, object
);
1267 struct d3dx_technique
*technique
= get_valid_technique(base
, object
);
1271 *annotations
= pass
->annotations
;
1272 return pass
->annotation_count
;
1276 *annotations
= technique
->annotations
;
1277 return technique
->annotation_count
;
1281 *annotations
= param
->annotations
;
1282 return param
->annotation_count
;
1286 FIXME("Functions are not handled, yet!\n");
1291 static D3DXHANDLE
d3dx9_base_effect_get_annotation(struct d3dx9_base_effect
*base
,
1292 D3DXHANDLE object
, UINT index
)
1294 struct d3dx_parameter
*annotations
= NULL
;
1295 UINT annotation_count
= 0;
1297 annotation_count
= get_annotation_from_object(base
, object
, &annotations
);
1299 if (index
< annotation_count
)
1301 TRACE("Returning parameter %p\n", &annotations
[index
]);
1302 return get_parameter_handle(&annotations
[index
]);
1305 WARN("Annotation not found.\n");
1310 static D3DXHANDLE
d3dx9_base_effect_get_annotation_by_name(struct d3dx9_base_effect
*base
,
1311 D3DXHANDLE object
, const char *name
)
1313 struct d3dx_parameter
*annotation
= NULL
;
1314 struct d3dx_parameter
*annotations
= NULL
;
1315 UINT annotation_count
= 0;
1319 WARN("Invalid argument specified\n");
1323 annotation_count
= get_annotation_from_object(base
, object
, &annotations
);
1325 annotation
= get_annotation_by_name(annotation_count
, annotations
, name
);
1328 TRACE("Returning parameter %p\n", annotation
);
1329 return get_parameter_handle(annotation
);
1332 WARN("Annotation not found.\n");
1337 static HRESULT
d3dx9_base_effect_set_value(struct d3dx9_base_effect
*base
,
1338 D3DXHANDLE parameter
, const void *data
, UINT bytes
)
1340 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1344 WARN("Invalid parameter %p specified\n", parameter
);
1345 return D3DERR_INVALIDCALL
;
1348 /* samplers don't touch data */
1349 if (param
->class == D3DXPC_OBJECT
&& (param
->type
== D3DXPT_SAMPLER
1350 || param
->type
== D3DXPT_SAMPLER1D
|| param
->type
== D3DXPT_SAMPLER2D
1351 || param
->type
== D3DXPT_SAMPLER3D
|| param
->type
== D3DXPT_SAMPLERCUBE
))
1353 TRACE("Sampler: returning E_FAIL\n");
1357 if (data
&& param
->bytes
<= bytes
)
1359 switch (param
->type
)
1365 TRACE("Copy %u bytes\n", param
->bytes
);
1366 memcpy(param
->data
, data
, param
->bytes
);
1370 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
1377 WARN("Invalid argument specified\n");
1379 return D3DERR_INVALIDCALL
;
1382 static HRESULT
d3dx9_base_effect_get_value(struct d3dx9_base_effect
*base
,
1383 D3DXHANDLE parameter
, void *data
, UINT bytes
)
1385 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1389 WARN("Invalid parameter %p specified\n", parameter
);
1390 return D3DERR_INVALIDCALL
;
1393 /* samplers don't touch data */
1394 if (param
->class == D3DXPC_OBJECT
&& (param
->type
== D3DXPT_SAMPLER
1395 || param
->type
== D3DXPT_SAMPLER1D
|| param
->type
== D3DXPT_SAMPLER2D
1396 || param
->type
== D3DXPT_SAMPLER3D
|| param
->type
== D3DXPT_SAMPLERCUBE
))
1398 TRACE("Sampler: returning E_FAIL\n");
1402 if (data
&& param
->bytes
<= bytes
)
1404 TRACE("Type %s\n", debug_d3dxparameter_type(param
->type
));
1406 switch (param
->type
)
1415 case D3DXPT_VERTEXSHADER
:
1416 case D3DXPT_PIXELSHADER
:
1417 case D3DXPT_TEXTURE
:
1418 case D3DXPT_TEXTURE1D
:
1419 case D3DXPT_TEXTURE2D
:
1420 case D3DXPT_TEXTURE3D
:
1421 case D3DXPT_TEXTURECUBE
:
1425 for (i
= 0; i
< (param
->element_count
? param
->element_count
: 1); ++i
)
1427 IUnknown
*unk
= ((IUnknown
**)param
->data
)[i
];
1428 if (unk
) IUnknown_AddRef(unk
);
1434 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
1438 TRACE("Copy %u bytes\n", param
->bytes
);
1439 memcpy(data
, param
->data
, param
->bytes
);
1443 WARN("Parameter not found.\n");
1445 return D3DERR_INVALIDCALL
;
1448 static HRESULT
d3dx9_base_effect_set_bool(struct d3dx9_base_effect
*base
, D3DXHANDLE parameter
, BOOL b
)
1450 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1452 if (param
&& !param
->element_count
&& param
->rows
== 1 && param
->columns
== 1)
1454 set_number(param
->data
, param
->type
, &b
, D3DXPT_BOOL
);
1458 WARN("Parameter not found.\n");
1460 return D3DERR_INVALIDCALL
;
1463 static HRESULT
d3dx9_base_effect_get_bool(struct d3dx9_base_effect
*base
, D3DXHANDLE parameter
, BOOL
*b
)
1465 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1467 if (b
&& param
&& !param
->element_count
&& param
->rows
== 1 && param
->columns
== 1)
1469 set_number(b
, D3DXPT_BOOL
, param
->data
, param
->type
);
1470 TRACE("Returning %s\n", *b
? "TRUE" : "FALSE");
1474 WARN("Parameter not found.\n");
1476 return D3DERR_INVALIDCALL
;
1479 static HRESULT
d3dx9_base_effect_set_bool_array(struct d3dx9_base_effect
*base
,
1480 D3DXHANDLE parameter
, const BOOL
*b
, UINT count
)
1482 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1486 UINT i
, size
= min(count
, param
->bytes
/ sizeof(DWORD
));
1488 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
1490 switch (param
->class)
1494 case D3DXPC_MATRIX_ROWS
:
1495 for (i
= 0; i
< size
; ++i
)
1497 /* don't crop the input, use D3DXPT_INT instead of D3DXPT_BOOL */
1498 set_number((DWORD
*)param
->data
+ i
, param
->type
, &b
[i
], D3DXPT_INT
);
1507 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
1512 WARN("Parameter not found.\n");
1514 return D3DERR_INVALIDCALL
;
1517 static HRESULT
d3dx9_base_effect_get_bool_array(struct d3dx9_base_effect
*base
,
1518 D3DXHANDLE parameter
, BOOL
*b
, UINT count
)
1520 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1522 if (b
&& param
&& (param
->class == D3DXPC_SCALAR
1523 || param
->class == D3DXPC_VECTOR
1524 || param
->class == D3DXPC_MATRIX_ROWS
1525 || param
->class == D3DXPC_MATRIX_COLUMNS
))
1527 UINT i
, size
= min(count
, param
->bytes
/ sizeof(DWORD
));
1529 for (i
= 0; i
< size
; ++i
)
1531 set_number(&b
[i
], D3DXPT_BOOL
, (DWORD
*)param
->data
+ i
, param
->type
);
1536 WARN("Parameter not found.\n");
1538 return D3DERR_INVALIDCALL
;
1541 static HRESULT
d3dx9_base_effect_set_int(struct d3dx9_base_effect
*base
, D3DXHANDLE parameter
, INT n
)
1543 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1545 if (param
&& !param
->element_count
)
1547 if (param
->rows
== 1 && param
->columns
== 1)
1549 set_number(param
->data
, param
->type
, &n
, D3DXPT_INT
);
1554 * Split the value, if parameter is a vector with dimension 3 or 4.
1556 if (param
->type
== D3DXPT_FLOAT
&&
1557 ((param
->class == D3DXPC_VECTOR
&& param
->columns
!= 2) ||
1558 (param
->class == D3DXPC_MATRIX_ROWS
&& param
->rows
!= 2 && param
->columns
== 1)))
1560 TRACE("Vector fixup\n");
1562 *(FLOAT
*)param
->data
= ((n
& 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE
;
1563 ((FLOAT
*)param
->data
)[1] = ((n
& 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE
;
1564 ((FLOAT
*)param
->data
)[2] = (n
& 0xff) * INT_FLOAT_MULTI_INVERSE
;
1565 if (param
->rows
* param
->columns
> 3)
1567 ((FLOAT
*)param
->data
)[3] = ((n
& 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE
;
1573 WARN("Parameter not found.\n");
1575 return D3DERR_INVALIDCALL
;
1578 static HRESULT
d3dx9_base_effect_get_int(struct d3dx9_base_effect
*base
, D3DXHANDLE parameter
, INT
*n
)
1580 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1582 if (n
&& param
&& !param
->element_count
)
1584 if (param
->columns
== 1 && param
->rows
== 1)
1586 set_number(n
, D3DXPT_INT
, param
->data
, param
->type
);
1587 TRACE("Returning %i\n", *n
);
1591 if (param
->type
== D3DXPT_FLOAT
&&
1592 ((param
->class == D3DXPC_VECTOR
&& param
->columns
!= 2)
1593 || (param
->class == D3DXPC_MATRIX_ROWS
&& param
->rows
!= 2 && param
->columns
== 1)))
1595 TRACE("Vector fixup\n");
1597 /* all components (3,4) are clamped (0,255) and put in the INT */
1598 *n
= (INT
)(min(max(0.0f
, *((FLOAT
*)param
->data
+ 2)), 1.0f
) * INT_FLOAT_MULTI
);
1599 *n
+= ((INT
)(min(max(0.0f
, *((FLOAT
*)param
->data
+ 1)), 1.0f
) * INT_FLOAT_MULTI
)) << 8;
1600 *n
+= ((INT
)(min(max(0.0f
, *((FLOAT
*)param
->data
+ 0)), 1.0f
) * INT_FLOAT_MULTI
)) << 16;
1601 if (param
->columns
* param
->rows
> 3)
1603 *n
+= ((INT
)(min(max(0.0f
, *((FLOAT
*)param
->data
+ 3)), 1.0f
) * INT_FLOAT_MULTI
)) << 24;
1606 TRACE("Returning %i\n", *n
);
1611 WARN("Parameter not found.\n");
1613 return D3DERR_INVALIDCALL
;
1616 static HRESULT
d3dx9_base_effect_set_int_array(struct d3dx9_base_effect
*base
,
1617 D3DXHANDLE parameter
, const INT
*n
, UINT count
)
1619 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1623 UINT i
, size
= min(count
, param
->bytes
/ sizeof(DWORD
));
1625 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
1627 switch (param
->class)
1631 case D3DXPC_MATRIX_ROWS
:
1632 for (i
= 0; i
< size
; ++i
)
1634 set_number((DWORD
*)param
->data
+ i
, param
->type
, &n
[i
], D3DXPT_INT
);
1643 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
1648 WARN("Parameter not found.\n");
1650 return D3DERR_INVALIDCALL
;
1653 static HRESULT
d3dx9_base_effect_get_int_array(struct d3dx9_base_effect
*base
,
1654 D3DXHANDLE parameter
, INT
*n
, UINT count
)
1656 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1658 if (n
&& param
&& (param
->class == D3DXPC_SCALAR
1659 || param
->class == D3DXPC_VECTOR
1660 || param
->class == D3DXPC_MATRIX_ROWS
1661 || param
->class == D3DXPC_MATRIX_COLUMNS
))
1663 UINT i
, size
= min(count
, param
->bytes
/ sizeof(DWORD
));
1665 for (i
= 0; i
< size
; ++i
)
1667 set_number(&n
[i
], D3DXPT_INT
, (DWORD
*)param
->data
+ i
, param
->type
);
1672 WARN("Parameter not found.\n");
1674 return D3DERR_INVALIDCALL
;
1677 static HRESULT
d3dx9_base_effect_set_float(struct d3dx9_base_effect
*base
, D3DXHANDLE parameter
, float f
)
1679 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1681 if (param
&& !param
->element_count
&& param
->rows
== 1 && param
->columns
== 1)
1683 set_number((DWORD
*)param
->data
, param
->type
, &f
, D3DXPT_FLOAT
);
1687 WARN("Parameter not found.\n");
1689 return D3DERR_INVALIDCALL
;
1692 static HRESULT
d3dx9_base_effect_get_float(struct d3dx9_base_effect
*base
, D3DXHANDLE parameter
, float *f
)
1694 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1696 if (f
&& param
&& !param
->element_count
&& param
->columns
== 1 && param
->rows
== 1)
1698 set_number(f
, D3DXPT_FLOAT
, (DWORD
*)param
->data
, param
->type
);
1699 TRACE("Returning %f\n", *f
);
1703 WARN("Parameter not found.\n");
1705 return D3DERR_INVALIDCALL
;
1708 static HRESULT
d3dx9_base_effect_set_float_array(struct d3dx9_base_effect
*base
,
1709 D3DXHANDLE parameter
, const float *f
, UINT count
)
1711 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1715 UINT i
, size
= min(count
, param
->bytes
/ sizeof(DWORD
));
1717 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
1719 switch (param
->class)
1723 case D3DXPC_MATRIX_ROWS
:
1724 for (i
= 0; i
< size
; ++i
)
1726 set_number((DWORD
*)param
->data
+ i
, param
->type
, &f
[i
], D3DXPT_FLOAT
);
1735 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
1740 WARN("Parameter not found.\n");
1742 return D3DERR_INVALIDCALL
;
1745 static HRESULT
d3dx9_base_effect_get_float_array(struct d3dx9_base_effect
*base
,
1746 D3DXHANDLE parameter
, float *f
, UINT count
)
1748 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1750 if (f
&& param
&& (param
->class == D3DXPC_SCALAR
1751 || param
->class == D3DXPC_VECTOR
1752 || param
->class == D3DXPC_MATRIX_ROWS
1753 || param
->class == D3DXPC_MATRIX_COLUMNS
))
1755 UINT i
, size
= min(count
, param
->bytes
/ sizeof(DWORD
));
1757 for (i
= 0; i
< size
; ++i
)
1759 set_number(&f
[i
], D3DXPT_FLOAT
, (DWORD
*)param
->data
+ i
, param
->type
);
1764 WARN("Parameter not found.\n");
1766 return D3DERR_INVALIDCALL
;
1769 static HRESULT
d3dx9_base_effect_set_vector(struct d3dx9_base_effect
*base
,
1770 D3DXHANDLE parameter
, const D3DXVECTOR4
*vector
)
1772 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1774 if (param
&& !param
->element_count
)
1776 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
1778 switch (param
->class)
1782 if (param
->type
== D3DXPT_INT
&& param
->bytes
== 4)
1786 TRACE("INT fixup\n");
1787 tmp
= (DWORD
)(max(min(vector
->z
, 1.0f
), 0.0f
) * INT_FLOAT_MULTI
);
1788 tmp
+= ((DWORD
)(max(min(vector
->y
, 1.0f
), 0.0f
) * INT_FLOAT_MULTI
)) << 8;
1789 tmp
+= ((DWORD
)(max(min(vector
->x
, 1.0f
), 0.0f
) * INT_FLOAT_MULTI
)) << 16;
1790 tmp
+= ((DWORD
)(max(min(vector
->w
, 1.0f
), 0.0f
) * INT_FLOAT_MULTI
)) << 24;
1792 *(INT
*)param
->data
= tmp
;
1795 if (param
->type
== D3DXPT_FLOAT
)
1797 memcpy(param
->data
, vector
, param
->columns
* sizeof(float));
1801 set_vector(param
, vector
);
1804 case D3DXPC_MATRIX_ROWS
:
1810 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
1815 WARN("Parameter not found.\n");
1817 return D3DERR_INVALIDCALL
;
1820 static HRESULT
d3dx9_base_effect_get_vector(struct d3dx9_base_effect
*base
,
1821 D3DXHANDLE parameter
, D3DXVECTOR4
*vector
)
1823 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1825 if (vector
&& param
&& !param
->element_count
)
1827 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
1829 switch (param
->class)
1833 if (param
->type
== D3DXPT_INT
&& param
->bytes
== 4)
1835 TRACE("INT fixup\n");
1836 vector
->x
= (((*(INT
*)param
->data
) & 0xff0000) >> 16) * INT_FLOAT_MULTI_INVERSE
;
1837 vector
->y
= (((*(INT
*)param
->data
) & 0xff00) >> 8) * INT_FLOAT_MULTI_INVERSE
;
1838 vector
->z
= ((*(INT
*)param
->data
) & 0xff) * INT_FLOAT_MULTI_INVERSE
;
1839 vector
->w
= (((*(INT
*)param
->data
) & 0xff000000) >> 24) * INT_FLOAT_MULTI_INVERSE
;
1842 get_vector(param
, vector
);
1845 case D3DXPC_MATRIX_ROWS
:
1851 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
1856 WARN("Parameter not found.\n");
1858 return D3DERR_INVALIDCALL
;
1861 static HRESULT
d3dx9_base_effect_set_vector_array(struct d3dx9_base_effect
*base
,
1862 D3DXHANDLE parameter
, const D3DXVECTOR4
*vector
, UINT count
)
1864 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1866 if (param
&& param
->element_count
&& param
->element_count
>= count
)
1870 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
1872 switch (param
->class)
1875 if (param
->type
== D3DXPT_FLOAT
)
1877 if (param
->columns
== 4)
1878 memcpy(param
->data
, vector
, count
* 4 * sizeof(float));
1880 for (i
= 0; i
< count
; ++i
)
1881 memcpy((float *)param
->data
+ param
->columns
* i
, vector
+ i
,
1882 param
->columns
* sizeof(float));
1886 for (i
= 0; i
< count
; ++i
)
1888 set_vector(¶m
->members
[i
], &vector
[i
]);
1893 case D3DXPC_MATRIX_ROWS
:
1899 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
1904 WARN("Parameter not found.\n");
1906 return D3DERR_INVALIDCALL
;
1909 static HRESULT
d3dx9_base_effect_get_vector_array(struct d3dx9_base_effect
*base
,
1910 D3DXHANDLE parameter
, D3DXVECTOR4
*vector
, UINT count
)
1912 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1914 if (!count
) return D3D_OK
;
1916 if (vector
&& param
&& count
<= param
->element_count
)
1920 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
1922 switch (param
->class)
1925 for (i
= 0; i
< count
; ++i
)
1927 get_vector(¶m
->members
[i
], &vector
[i
]);
1932 case D3DXPC_MATRIX_ROWS
:
1938 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
1943 WARN("Parameter not found.\n");
1945 return D3DERR_INVALIDCALL
;
1948 static HRESULT
d3dx9_base_effect_set_matrix(struct d3dx9_base_effect
*base
,
1949 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
)
1951 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1953 if (param
&& !param
->element_count
)
1955 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
1957 switch (param
->class)
1959 case D3DXPC_MATRIX_ROWS
:
1960 set_matrix(param
, matrix
);
1970 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
1975 WARN("Parameter not found.\n");
1977 return D3DERR_INVALIDCALL
;
1980 static HRESULT
d3dx9_base_effect_get_matrix(struct d3dx9_base_effect
*base
,
1981 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
1983 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1985 if (matrix
&& param
&& !param
->element_count
)
1987 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
1989 switch (param
->class)
1991 case D3DXPC_MATRIX_ROWS
:
1992 get_matrix(param
, matrix
, FALSE
);
2002 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2007 WARN("Parameter not found.\n");
2009 return D3DERR_INVALIDCALL
;
2012 static HRESULT
d3dx9_base_effect_set_matrix_array(struct d3dx9_base_effect
*base
,
2013 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
, UINT count
)
2015 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
2017 if (param
&& param
->element_count
>= count
)
2021 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2023 switch (param
->class)
2025 case D3DXPC_MATRIX_ROWS
:
2026 for (i
= 0; i
< count
; ++i
)
2028 set_matrix(¶m
->members
[i
], &matrix
[i
]);
2039 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2044 WARN("Parameter not found.\n");
2046 return D3DERR_INVALIDCALL
;
2049 static HRESULT
d3dx9_base_effect_get_matrix_array(struct d3dx9_base_effect
*base
,
2050 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
2052 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
2054 if (!count
) return D3D_OK
;
2056 if (matrix
&& param
&& count
<= param
->element_count
)
2060 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2062 switch (param
->class)
2064 case D3DXPC_MATRIX_ROWS
:
2065 for (i
= 0; i
< count
; ++i
)
2067 get_matrix(¶m
->members
[i
], &matrix
[i
], FALSE
);
2078 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2083 WARN("Parameter not found.\n");
2085 return D3DERR_INVALIDCALL
;
2088 static HRESULT
d3dx9_base_effect_set_matrix_pointer_array(struct d3dx9_base_effect
*base
,
2089 D3DXHANDLE parameter
, const D3DXMATRIX
**matrix
, UINT count
)
2091 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
2093 if (param
&& count
<= param
->element_count
)
2097 switch (param
->class)
2099 case D3DXPC_MATRIX_ROWS
:
2100 for (i
= 0; i
< count
; ++i
)
2102 set_matrix(¶m
->members
[i
], matrix
[i
]);
2112 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2117 WARN("Parameter not found.\n");
2119 return D3DERR_INVALIDCALL
;
2122 static HRESULT
d3dx9_base_effect_get_matrix_pointer_array(struct d3dx9_base_effect
*base
,
2123 D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
2125 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
2127 if (!count
) return D3D_OK
;
2129 if (param
&& matrix
&& count
<= param
->element_count
)
2133 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2135 switch (param
->class)
2137 case D3DXPC_MATRIX_ROWS
:
2138 for (i
= 0; i
< count
; ++i
)
2140 get_matrix(¶m
->members
[i
], matrix
[i
], FALSE
);
2150 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2155 WARN("Parameter not found.\n");
2157 return D3DERR_INVALIDCALL
;
2160 static HRESULT
d3dx9_base_effect_set_matrix_transpose(struct d3dx9_base_effect
*base
,
2161 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
)
2163 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
2165 if (param
&& !param
->element_count
)
2167 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2169 switch (param
->class)
2171 case D3DXPC_MATRIX_ROWS
:
2172 set_matrix_transpose(param
, matrix
);
2182 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2187 WARN("Parameter not found.\n");
2189 return D3DERR_INVALIDCALL
;
2192 static HRESULT
d3dx9_base_effect_get_matrix_transpose(struct d3dx9_base_effect
*base
,
2193 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
2195 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
2197 if (matrix
&& param
&& !param
->element_count
)
2199 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2201 switch (param
->class)
2205 get_matrix(param
, matrix
, FALSE
);
2208 case D3DXPC_MATRIX_ROWS
:
2209 get_matrix(param
, matrix
, TRUE
);
2217 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2222 WARN("Parameter not found.\n");
2224 return D3DERR_INVALIDCALL
;
2227 static HRESULT
d3dx9_base_effect_set_matrix_transpose_array(struct d3dx9_base_effect
*base
,
2228 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
, UINT count
)
2230 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
2232 if (param
&& param
->element_count
>= count
)
2236 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2238 switch (param
->class)
2240 case D3DXPC_MATRIX_ROWS
:
2241 for (i
= 0; i
< count
; ++i
)
2243 set_matrix_transpose(¶m
->members
[i
], &matrix
[i
]);
2254 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2259 WARN("Parameter not found.\n");
2261 return D3DERR_INVALIDCALL
;
2264 static HRESULT
d3dx9_base_effect_get_matrix_transpose_array(struct d3dx9_base_effect
*base
,
2265 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
2267 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
2269 if (!count
) return D3D_OK
;
2271 if (matrix
&& param
&& count
<= param
->element_count
)
2275 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2277 switch (param
->class)
2279 case D3DXPC_MATRIX_ROWS
:
2280 for (i
= 0; i
< count
; ++i
)
2282 get_matrix(¶m
->members
[i
], &matrix
[i
], TRUE
);
2293 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2298 WARN("Parameter not found.\n");
2300 return D3DERR_INVALIDCALL
;
2303 static HRESULT
d3dx9_base_effect_set_matrix_transpose_pointer_array(struct d3dx9_base_effect
*base
,
2304 D3DXHANDLE parameter
, const D3DXMATRIX
**matrix
, UINT count
)
2306 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
2308 if (param
&& count
<= param
->element_count
)
2312 switch (param
->class)
2314 case D3DXPC_MATRIX_ROWS
:
2315 for (i
= 0; i
< count
; ++i
)
2317 set_matrix_transpose(¶m
->members
[i
], matrix
[i
]);
2327 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2332 WARN("Parameter not found.\n");
2334 return D3DERR_INVALIDCALL
;
2337 static HRESULT
d3dx9_base_effect_get_matrix_transpose_pointer_array(struct d3dx9_base_effect
*base
,
2338 D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
2340 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
2342 if (!count
) return D3D_OK
;
2344 if (matrix
&& param
&& count
<= param
->element_count
)
2348 TRACE("Class %s\n", debug_d3dxparameter_class(param
->class));
2350 switch (param
->class)
2352 case D3DXPC_MATRIX_ROWS
:
2353 for (i
= 0; i
< count
; ++i
)
2355 get_matrix(¶m
->members
[i
], matrix
[i
], TRUE
);
2365 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
2370 WARN("Parameter not found.\n");
2372 return D3DERR_INVALIDCALL
;
2375 static HRESULT
d3dx9_base_effect_set_string(struct d3dx9_base_effect
*base
,
2376 D3DXHANDLE parameter
, const char *string
)
2383 static HRESULT
d3dx9_base_effect_get_string(struct d3dx9_base_effect
*base
,
2384 D3DXHANDLE parameter
, const char **string
)
2386 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
2388 if (string
&& param
&& !param
->element_count
&& param
->type
== D3DXPT_STRING
)
2390 *string
= *(const char **)param
->data
;
2391 TRACE("Returning %s.\n", debugstr_a(*string
));
2395 WARN("Parameter not found.\n");
2397 return D3DERR_INVALIDCALL
;
2400 static HRESULT
d3dx9_base_effect_set_texture(struct d3dx9_base_effect
*base
,
2401 D3DXHANDLE parameter
, struct IDirect3DBaseTexture9
*texture
)
2403 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
2405 if (param
&& !param
->element_count
&&
2406 (param
->type
== D3DXPT_TEXTURE
|| param
->type
== D3DXPT_TEXTURE1D
2407 || param
->type
== D3DXPT_TEXTURE2D
|| param
->type
== D3DXPT_TEXTURE3D
2408 || param
->type
== D3DXPT_TEXTURECUBE
))
2410 struct IDirect3DBaseTexture9
*oltexture
= *(struct IDirect3DBaseTexture9
**)param
->data
;
2412 if (texture
== oltexture
)
2415 if (texture
) IDirect3DBaseTexture9_AddRef(texture
);
2416 if (oltexture
) IDirect3DBaseTexture9_Release(oltexture
);
2418 *(struct IDirect3DBaseTexture9
**)param
->data
= texture
;
2423 WARN("Parameter not found.\n");
2425 return D3DERR_INVALIDCALL
;
2428 static HRESULT
d3dx9_base_effect_get_texture(struct d3dx9_base_effect
*base
,
2429 D3DXHANDLE parameter
, struct IDirect3DBaseTexture9
**texture
)
2431 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
2433 if (texture
&& param
&& !param
->element_count
&&
2434 (param
->type
== D3DXPT_TEXTURE
|| param
->type
== D3DXPT_TEXTURE1D
2435 || param
->type
== D3DXPT_TEXTURE2D
|| param
->type
== D3DXPT_TEXTURE3D
2436 || param
->type
== D3DXPT_TEXTURECUBE
))
2438 *texture
= *(struct IDirect3DBaseTexture9
**)param
->data
;
2439 if (*texture
) IDirect3DBaseTexture9_AddRef(*texture
);
2440 TRACE("Returning %p\n", *texture
);
2444 WARN("Parameter not found.\n");
2446 return D3DERR_INVALIDCALL
;
2449 static HRESULT
d3dx9_base_effect_get_pixel_shader(struct d3dx9_base_effect
*base
,
2450 D3DXHANDLE parameter
, struct IDirect3DPixelShader9
**shader
)
2452 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
2454 if (shader
&& param
&& !param
->element_count
&& param
->type
== D3DXPT_PIXELSHADER
)
2456 if ((*shader
= *(struct IDirect3DPixelShader9
**)param
->data
))
2457 IDirect3DPixelShader9_AddRef(*shader
);
2458 TRACE("Returning %p.\n", *shader
);
2462 WARN("Parameter not found.\n");
2464 return D3DERR_INVALIDCALL
;
2467 static HRESULT
d3dx9_base_effect_get_vertex_shader(struct d3dx9_base_effect
*base
,
2468 D3DXHANDLE parameter
, struct IDirect3DVertexShader9
**shader
)
2470 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
2472 if (shader
&& param
&& !param
->element_count
&& param
->type
== D3DXPT_VERTEXSHADER
)
2474 if ((*shader
= *(struct IDirect3DVertexShader9
**)param
->data
))
2475 IDirect3DVertexShader9_AddRef(*shader
);
2476 TRACE("Returning %p.\n", *shader
);
2480 WARN("Parameter not found.\n");
2482 return D3DERR_INVALIDCALL
;
2485 static HRESULT
d3dx9_base_effect_set_array_range(struct d3dx9_base_effect
*base
,
2486 D3DXHANDLE parameter
, UINT start
, UINT end
)
2493 static inline struct ID3DXEffectImpl
*impl_from_ID3DXEffect(ID3DXEffect
*iface
)
2495 return CONTAINING_RECORD(iface
, struct ID3DXEffectImpl
, ID3DXEffect_iface
);
2498 /*** IUnknown methods ***/
2499 static HRESULT WINAPI
ID3DXEffectImpl_QueryInterface(ID3DXEffect
*iface
, REFIID riid
, void **object
)
2501 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), object
);
2503 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
2504 IsEqualGUID(riid
, &IID_ID3DXEffect
))
2506 iface
->lpVtbl
->AddRef(iface
);
2511 ERR("Interface %s not found\n", debugstr_guid(riid
));
2513 return E_NOINTERFACE
;
2516 static ULONG WINAPI
ID3DXEffectImpl_AddRef(ID3DXEffect
*iface
)
2518 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2520 TRACE("(%p)->(): AddRef from %u\n", This
, This
->ref
);
2522 return InterlockedIncrement(&This
->ref
);
2525 static ULONG WINAPI
ID3DXEffectImpl_Release(ID3DXEffect
*iface
)
2527 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2528 ULONG ref
= InterlockedDecrement(&This
->ref
);
2530 TRACE("(%p)->(): Release from %u\n", This
, ref
+ 1);
2535 HeapFree(GetProcessHeap(), 0, This
);
2541 /*** ID3DXBaseEffect methods ***/
2542 static HRESULT WINAPI
ID3DXEffectImpl_GetDesc(ID3DXEffect
*iface
, D3DXEFFECT_DESC
*desc
)
2544 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2546 TRACE("iface %p, desc %p.\n", iface
, desc
);
2548 return d3dx9_base_effect_get_desc(&effect
->base_effect
, desc
);
2551 static HRESULT WINAPI
ID3DXEffectImpl_GetParameterDesc(ID3DXEffect
*iface
,
2552 D3DXHANDLE parameter
, D3DXPARAMETER_DESC
*desc
)
2554 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2556 TRACE("iface %p, parameter %p, desc %p.\n", iface
, parameter
, desc
);
2558 return d3dx9_base_effect_get_parameter_desc(&effect
->base_effect
, parameter
, desc
);
2561 static HRESULT WINAPI
ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect
*iface
,
2562 D3DXHANDLE technique
, D3DXTECHNIQUE_DESC
*desc
)
2564 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2566 TRACE("iface %p, technique %p, desc %p.\n", iface
, technique
, desc
);
2568 return d3dx9_base_effect_get_technique_desc(&effect
->base_effect
, technique
, desc
);
2571 static HRESULT WINAPI
ID3DXEffectImpl_GetPassDesc(ID3DXEffect
*iface
, D3DXHANDLE pass
, D3DXPASS_DESC
*desc
)
2573 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2575 TRACE("iface %p, pass %p, desc %p.\n", iface
, pass
, desc
);
2577 return d3dx9_base_effect_get_pass_desc(&effect
->base_effect
, pass
, desc
);
2580 static HRESULT WINAPI
ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect
*iface
, D3DXHANDLE shader
, D3DXFUNCTION_DESC
*desc
)
2582 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2584 TRACE("iface %p, shader %p, desc %p.\n", iface
, shader
, desc
);
2586 return d3dx9_base_effect_get_function_desc(&effect
->base_effect
, shader
, desc
);
2589 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameter(ID3DXEffect
*iface
, D3DXHANDLE parameter
, UINT index
)
2591 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2593 TRACE("iface %p, parameter %p, index %u.\n", iface
, parameter
, index
);
2595 return d3dx9_base_effect_get_parameter(&effect
->base_effect
, parameter
, index
);
2598 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameterByName(ID3DXEffect
*iface
,
2599 D3DXHANDLE parameter
, const char *name
)
2601 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2603 TRACE("iface %p, parameter %p, name %s.\n", iface
, parameter
, debugstr_a(name
));
2605 return d3dx9_base_effect_get_parameter_by_name(&effect
->base_effect
, parameter
, name
);
2608 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect
*iface
,
2609 D3DXHANDLE parameter
, const char *semantic
)
2611 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2613 TRACE("iface %p, parameter %p, semantic %s.\n", iface
, parameter
, debugstr_a(semantic
));
2615 return d3dx9_base_effect_get_parameter_by_semantic(&effect
->base_effect
, parameter
, semantic
);
2618 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameterElement(ID3DXEffect
*iface
, D3DXHANDLE parameter
, UINT index
)
2620 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2622 TRACE("iface %p, parameter %p, index %u.\n", iface
, parameter
, index
);
2624 return d3dx9_base_effect_get_parameter_element(&effect
->base_effect
, parameter
, index
);
2627 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetTechnique(ID3DXEffect
*iface
, UINT index
)
2629 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2631 TRACE("iface %p, index %u.\n", iface
, index
);
2633 return d3dx9_base_effect_get_technique(&effect
->base_effect
, index
);
2636 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect
*iface
, const char *name
)
2638 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2640 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
2642 return d3dx9_base_effect_get_technique_by_name(&effect
->base_effect
, name
);
2645 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetPass(ID3DXEffect
*iface
, D3DXHANDLE technique
, UINT index
)
2647 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2649 TRACE("iface %p, technique %p, index %u.\n", iface
, technique
, index
);
2651 return d3dx9_base_effect_get_pass(&effect
->base_effect
, technique
, index
);
2654 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetPassByName(ID3DXEffect
*iface
,
2655 D3DXHANDLE technique
, const char *name
)
2657 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2659 TRACE("iface %p, technique %p, name %s.\n", iface
, technique
, debugstr_a(name
));
2661 return d3dx9_base_effect_get_pass_by_name(&effect
->base_effect
, technique
, name
);
2664 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetFunction(ID3DXEffect
*iface
, UINT index
)
2666 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2668 TRACE("iface %p, index %u.\n", iface
, index
);
2670 return d3dx9_base_effect_get_function(&effect
->base_effect
, index
);
2673 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetFunctionByName(ID3DXEffect
*iface
, const char *name
)
2675 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2677 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
2679 return d3dx9_base_effect_get_function_by_name(&effect
->base_effect
, name
);
2682 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetAnnotation(ID3DXEffect
*iface
, D3DXHANDLE object
, UINT index
)
2684 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2686 TRACE("iface %p, object %p, index %u.\n", iface
, object
, index
);
2688 return d3dx9_base_effect_get_annotation(&effect
->base_effect
, object
, index
);
2691 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect
*iface
,
2692 D3DXHANDLE object
, const char *name
)
2694 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2696 TRACE("iface %p, object %p, name %s.\n", iface
, object
, debugstr_a(name
));
2698 return d3dx9_base_effect_get_annotation_by_name(&effect
->base_effect
, object
, name
);
2701 static HRESULT WINAPI
ID3DXEffectImpl_SetValue(ID3DXEffect
*iface
,
2702 D3DXHANDLE parameter
, const void *data
, UINT bytes
)
2704 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2706 TRACE("iface %p, parameter %p, data %p, bytes %u.\n", iface
, parameter
, data
, bytes
);
2708 return d3dx9_base_effect_set_value(&effect
->base_effect
, parameter
, data
, bytes
);
2711 static HRESULT WINAPI
ID3DXEffectImpl_GetValue(ID3DXEffect
*iface
,
2712 D3DXHANDLE parameter
, void *data
, UINT bytes
)
2714 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2716 TRACE("iface %p, parameter %p, data %p, bytes %u.\n", iface
, parameter
, data
, bytes
);
2718 return d3dx9_base_effect_get_value(&effect
->base_effect
, parameter
, data
, bytes
);
2721 static HRESULT WINAPI
ID3DXEffectImpl_SetBool(ID3DXEffect
*iface
, D3DXHANDLE parameter
, BOOL b
)
2723 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2725 TRACE("iface %p, parameter %p, b %#x.\n", iface
, parameter
, b
);
2727 return d3dx9_base_effect_set_bool(&effect
->base_effect
, parameter
, b
);
2730 static HRESULT WINAPI
ID3DXEffectImpl_GetBool(ID3DXEffect
*iface
, D3DXHANDLE parameter
, BOOL
*b
)
2732 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2734 TRACE("iface %p, parameter %p, b %p.\n", iface
, parameter
, b
);
2736 return d3dx9_base_effect_get_bool(&effect
->base_effect
, parameter
, b
);
2739 static HRESULT WINAPI
ID3DXEffectImpl_SetBoolArray(ID3DXEffect
*iface
,
2740 D3DXHANDLE parameter
, const BOOL
*b
, UINT count
)
2742 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2744 TRACE("iface %p, parameter %p, b %p, count %u.\n", iface
, parameter
, b
, count
);
2746 return d3dx9_base_effect_set_bool_array(&effect
->base_effect
, parameter
, b
, count
);
2749 static HRESULT WINAPI
ID3DXEffectImpl_GetBoolArray(ID3DXEffect
*iface
,
2750 D3DXHANDLE parameter
, BOOL
*b
, UINT count
)
2752 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2754 TRACE("iface %p, parameter %p, b %p, count %u.\n", iface
, parameter
, b
, count
);
2756 return d3dx9_base_effect_get_bool_array(&effect
->base_effect
, parameter
, b
, count
);
2759 static HRESULT WINAPI
ID3DXEffectImpl_SetInt(ID3DXEffect
*iface
, D3DXHANDLE parameter
, INT n
)
2761 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2763 TRACE("iface %p, parameter %p, n %d.\n", iface
, parameter
, n
);
2765 return d3dx9_base_effect_set_int(&effect
->base_effect
, parameter
, n
);
2768 static HRESULT WINAPI
ID3DXEffectImpl_GetInt(ID3DXEffect
*iface
, D3DXHANDLE parameter
, INT
*n
)
2770 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2772 TRACE("iface %p, parameter %p, n %p.\n", iface
, parameter
, n
);
2774 return d3dx9_base_effect_get_int(&effect
->base_effect
, parameter
, n
);
2777 static HRESULT WINAPI
ID3DXEffectImpl_SetIntArray(ID3DXEffect
*iface
,
2778 D3DXHANDLE parameter
, const INT
*n
, UINT count
)
2780 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2782 TRACE("iface %p, parameter %p, n %p, count %u.\n", iface
, parameter
, n
, count
);
2784 return d3dx9_base_effect_set_int_array(&effect
->base_effect
, parameter
, n
, count
);
2787 static HRESULT WINAPI
ID3DXEffectImpl_GetIntArray(ID3DXEffect
*iface
,
2788 D3DXHANDLE parameter
, INT
*n
, UINT count
)
2790 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2792 TRACE("iface %p, parameter %p, n %p, count %u.\n", iface
, parameter
, n
, count
);
2794 return d3dx9_base_effect_get_int_array(&effect
->base_effect
, parameter
, n
, count
);
2797 static HRESULT WINAPI
ID3DXEffectImpl_SetFloat(ID3DXEffect
*iface
, D3DXHANDLE parameter
, float f
)
2799 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2801 TRACE("iface %p, parameter %p, f %.8e.\n", iface
, parameter
, f
);
2803 return d3dx9_base_effect_set_float(&effect
->base_effect
, parameter
, f
);
2806 static HRESULT WINAPI
ID3DXEffectImpl_GetFloat(ID3DXEffect
*iface
, D3DXHANDLE parameter
, float *f
)
2808 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2810 TRACE("iface %p, parameter %p, f %p.\n", iface
, parameter
, f
);
2812 return d3dx9_base_effect_get_float(&effect
->base_effect
, parameter
, f
);
2815 static HRESULT WINAPI
ID3DXEffectImpl_SetFloatArray(ID3DXEffect
*iface
,
2816 D3DXHANDLE parameter
, const float *f
, UINT count
)
2818 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2820 TRACE("iface %p, parameter %p, f %p, count %u.\n", iface
, parameter
, f
, count
);
2822 return d3dx9_base_effect_set_float_array(&effect
->base_effect
, parameter
, f
, count
);
2825 static HRESULT WINAPI
ID3DXEffectImpl_GetFloatArray(ID3DXEffect
*iface
,
2826 D3DXHANDLE parameter
, float *f
, UINT count
)
2828 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2830 TRACE("iface %p, parameter %p, f %p, count %u.\n", iface
, parameter
, f
, count
);
2832 return d3dx9_base_effect_get_float_array(&effect
->base_effect
, parameter
, f
, count
);
2835 static HRESULT WINAPI
ID3DXEffectImpl_SetVector(ID3DXEffect
*iface
,
2836 D3DXHANDLE parameter
, const D3DXVECTOR4
*vector
)
2838 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2840 TRACE("iface %p, parameter %p, vector %p.\n", iface
, parameter
, vector
);
2842 return d3dx9_base_effect_set_vector(&effect
->base_effect
, parameter
, vector
);
2845 static HRESULT WINAPI
ID3DXEffectImpl_GetVector(ID3DXEffect
*iface
,
2846 D3DXHANDLE parameter
, D3DXVECTOR4
*vector
)
2848 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2850 TRACE("iface %p, parameter %p, vector %p.\n", iface
, parameter
, vector
);
2852 return d3dx9_base_effect_get_vector(&effect
->base_effect
, parameter
, vector
);
2855 static HRESULT WINAPI
ID3DXEffectImpl_SetVectorArray(ID3DXEffect
*iface
,
2856 D3DXHANDLE parameter
, const D3DXVECTOR4
*vector
, UINT count
)
2858 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2860 TRACE("iface %p, parameter %p, vector %p, count %u.\n", iface
, parameter
, vector
, count
);
2862 return d3dx9_base_effect_set_vector_array(&effect
->base_effect
, parameter
, vector
, count
);
2865 static HRESULT WINAPI
ID3DXEffectImpl_GetVectorArray(ID3DXEffect
*iface
,
2866 D3DXHANDLE parameter
, D3DXVECTOR4
*vector
, UINT count
)
2868 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2870 TRACE("iface %p, parameter %p, vector %p, count %u.\n", iface
, parameter
, vector
, count
);
2872 return d3dx9_base_effect_get_vector_array(&effect
->base_effect
, parameter
, vector
, count
);
2875 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrix(ID3DXEffect
*iface
,
2876 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
)
2878 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2880 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
2882 return d3dx9_base_effect_set_matrix(&effect
->base_effect
, parameter
, matrix
);
2885 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrix(ID3DXEffect
*iface
,
2886 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
2888 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2890 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
2892 return d3dx9_base_effect_get_matrix(&effect
->base_effect
, parameter
, matrix
);
2895 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixArray(ID3DXEffect
*iface
,
2896 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
, UINT count
)
2898 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2900 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
2902 return d3dx9_base_effect_set_matrix_array(&effect
->base_effect
, parameter
, matrix
, count
);
2905 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixArray(ID3DXEffect
*iface
,
2906 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
2908 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2910 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
2912 return d3dx9_base_effect_get_matrix_array(&effect
->base_effect
, parameter
, matrix
, count
);
2915 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect
*iface
,
2916 D3DXHANDLE parameter
, const D3DXMATRIX
**matrix
, UINT count
)
2918 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2920 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
2922 return d3dx9_base_effect_set_matrix_pointer_array(&effect
->base_effect
, parameter
, matrix
, count
);
2925 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect
*iface
,
2926 D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
2928 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2930 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
2932 return d3dx9_base_effect_get_matrix_pointer_array(&effect
->base_effect
, parameter
, matrix
, count
);
2935 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect
*iface
,
2936 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
)
2938 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2940 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
2942 return d3dx9_base_effect_set_matrix_transpose(&effect
->base_effect
, parameter
, matrix
);
2945 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect
*iface
,
2946 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
2948 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2950 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
2952 return d3dx9_base_effect_get_matrix_transpose(&effect
->base_effect
, parameter
, matrix
);
2955 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect
*iface
,
2956 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
, UINT count
)
2958 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2960 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
2962 return d3dx9_base_effect_set_matrix_transpose_array(&effect
->base_effect
, parameter
, matrix
, count
);
2965 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect
*iface
,
2966 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
2968 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2970 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
2972 return d3dx9_base_effect_get_matrix_transpose_array(&effect
->base_effect
, parameter
, matrix
, count
);
2975 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect
*iface
,
2976 D3DXHANDLE parameter
, const D3DXMATRIX
**matrix
, UINT count
)
2978 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2980 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
2982 return d3dx9_base_effect_set_matrix_transpose_pointer_array(&effect
->base_effect
, parameter
, matrix
, count
);
2985 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect
*iface
,
2986 D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
2988 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2990 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
2992 return d3dx9_base_effect_get_matrix_transpose_pointer_array(&effect
->base_effect
, parameter
, matrix
, count
);
2995 static HRESULT WINAPI
ID3DXEffectImpl_SetString(ID3DXEffect
*iface
, D3DXHANDLE parameter
, const char *string
)
2997 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2999 TRACE("iface %p, parameter %p, string %s.\n", iface
, parameter
, debugstr_a(string
));
3001 return d3dx9_base_effect_set_string(&effect
->base_effect
, parameter
, string
);
3004 static HRESULT WINAPI
ID3DXEffectImpl_GetString(ID3DXEffect
*iface
, D3DXHANDLE parameter
, const char **string
)
3006 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3008 TRACE("iface %p, parameter %p, string %p.\n", iface
, parameter
, string
);
3010 return d3dx9_base_effect_get_string(&effect
->base_effect
, parameter
, string
);
3013 static HRESULT WINAPI
ID3DXEffectImpl_SetTexture(struct ID3DXEffect
*iface
,
3014 D3DXHANDLE parameter
, struct IDirect3DBaseTexture9
*texture
)
3016 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3018 TRACE("iface %p, parameter %p, texture %p.\n", iface
, parameter
, texture
);
3020 return d3dx9_base_effect_set_texture(&effect
->base_effect
, parameter
, texture
);
3023 static HRESULT WINAPI
ID3DXEffectImpl_GetTexture(struct ID3DXEffect
*iface
,
3024 D3DXHANDLE parameter
, struct IDirect3DBaseTexture9
**texture
)
3026 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3028 TRACE("iface %p, parameter %p, texture %p.\n", iface
, parameter
, texture
);
3030 return d3dx9_base_effect_get_texture(&effect
->base_effect
, parameter
, texture
);
3033 static HRESULT WINAPI
ID3DXEffectImpl_GetPixelShader(ID3DXEffect
*iface
,
3034 D3DXHANDLE parameter
, struct IDirect3DPixelShader9
**shader
)
3036 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3038 TRACE("iface %p, parameter %p, shader %p.\n", iface
, parameter
, shader
);
3040 return d3dx9_base_effect_get_pixel_shader(&effect
->base_effect
, parameter
, shader
);
3043 static HRESULT WINAPI
ID3DXEffectImpl_GetVertexShader(struct ID3DXEffect
*iface
,
3044 D3DXHANDLE parameter
, struct IDirect3DVertexShader9
**shader
)
3046 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3048 TRACE("iface %p, parameter %p, shader %p.\n", iface
, parameter
, shader
);
3050 return d3dx9_base_effect_get_vertex_shader(&effect
->base_effect
, parameter
, shader
);
3053 static HRESULT WINAPI
ID3DXEffectImpl_SetArrayRange(ID3DXEffect
*iface
, D3DXHANDLE parameter
, UINT start
, UINT end
)
3055 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3057 TRACE("iface %p, parameter %p, start %u, end %u.\n", iface
, parameter
, start
, end
);
3059 return d3dx9_base_effect_set_array_range(&effect
->base_effect
, parameter
, start
, end
);
3062 /*** ID3DXEffect methods ***/
3063 static HRESULT WINAPI
ID3DXEffectImpl_GetPool(ID3DXEffect
*iface
, ID3DXEffectPool
**pool
)
3065 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3067 TRACE("iface %p, pool %p\n", This
, pool
);
3071 WARN("Invalid argument supplied.\n");
3072 return D3DERR_INVALIDCALL
;
3077 This
->pool
->lpVtbl
->AddRef(This
->pool
);
3082 TRACE("Returning pool %p\n", *pool
);
3087 static HRESULT WINAPI
ID3DXEffectImpl_SetTechnique(ID3DXEffect
*iface
, D3DXHANDLE technique
)
3089 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3090 struct d3dx9_base_effect
*base
= &This
->base_effect
;
3091 struct d3dx_technique
*tech
= get_valid_technique(base
, technique
);
3093 TRACE("iface %p, technique %p\n", This
, technique
);
3097 This
->active_technique
= tech
;
3098 TRACE("Technique %p\n", tech
);
3102 WARN("Technique not found.\n");
3104 return D3DERR_INVALIDCALL
;
3107 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect
*iface
)
3109 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3111 TRACE("iface %p\n", This
);
3113 return get_technique_handle(This
->active_technique
);
3116 static HRESULT WINAPI
ID3DXEffectImpl_ValidateTechnique(ID3DXEffect
* iface
, D3DXHANDLE technique
)
3118 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3120 FIXME("(%p)->(%p): stub\n", This
, technique
);
3125 static HRESULT WINAPI
ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect
* iface
, D3DXHANDLE technique
, D3DXHANDLE
* next_technique
)
3127 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3129 FIXME("(%p)->(%p, %p): stub\n", This
, technique
, next_technique
);
3134 static BOOL WINAPI
ID3DXEffectImpl_IsParameterUsed(ID3DXEffect
* iface
, D3DXHANDLE parameter
, D3DXHANDLE technique
)
3136 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3138 FIXME("(%p)->(%p, %p): stub\n", This
, parameter
, technique
);
3143 static HRESULT WINAPI
ID3DXEffectImpl_Begin(ID3DXEffect
*iface
, UINT
*passes
, DWORD flags
)
3145 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3146 struct d3dx_technique
*technique
= This
->active_technique
;
3148 TRACE("iface %p, passes %p, flags %#x.\n", iface
, passes
, flags
);
3150 if (passes
&& technique
)
3152 if (flags
& ~(D3DXFX_DONOTSAVESTATE
| D3DXFX_DONOTSAVESAMPLERSTATE
| D3DXFX_DONOTSAVESHADERSTATE
))
3153 WARN("Invalid flags (%#x) specified.\n", flags
);
3155 if (This
->manager
|| flags
& D3DXFX_DONOTSAVESTATE
)
3157 TRACE("State capturing disabled.\n");
3161 FIXME("State capturing not supported, yet!\n");
3164 *passes
= technique
->pass_count
;
3165 This
->started
= TRUE
;
3166 This
->flags
= flags
;
3171 WARN("Invalid argument supplied.\n");
3173 return D3DERR_INVALIDCALL
;
3176 static HRESULT WINAPI
ID3DXEffectImpl_BeginPass(ID3DXEffect
*iface
, UINT pass
)
3178 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3179 struct d3dx_technique
*technique
= This
->active_technique
;
3181 TRACE("iface %p, pass %u\n", This
, pass
);
3183 if (technique
&& pass
< technique
->pass_count
&& !This
->active_pass
)
3185 This
->active_pass
= &technique
->passes
[pass
];
3187 FIXME("No states applied, yet!\n");
3192 WARN("Invalid argument supplied.\n");
3194 return D3DERR_INVALIDCALL
;
3197 static HRESULT WINAPI
ID3DXEffectImpl_CommitChanges(ID3DXEffect
* iface
)
3199 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3201 FIXME("(%p)->(): stub\n", This
);
3203 if (!This
->active_pass
)
3205 WARN("Called without an active pass.\n");
3212 static HRESULT WINAPI
ID3DXEffectImpl_EndPass(ID3DXEffect
*iface
)
3214 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3216 TRACE("iface %p\n", This
);
3218 if (This
->active_pass
)
3220 This
->active_pass
= NULL
;
3224 WARN("Invalid call.\n");
3226 return D3DERR_INVALIDCALL
;
3229 static HRESULT WINAPI
ID3DXEffectImpl_End(ID3DXEffect
*iface
)
3231 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3233 TRACE("iface %p.\n", iface
);
3238 if (This
->manager
|| This
->flags
& D3DXFX_DONOTSAVESTATE
)
3240 TRACE("State restoring disabled.\n");
3244 FIXME("State restoring not supported, yet!\n");
3247 This
->started
= FALSE
;
3252 static HRESULT WINAPI
ID3DXEffectImpl_GetDevice(ID3DXEffect
*iface
, struct IDirect3DDevice9
**device
)
3254 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3256 TRACE("iface %p, device %p\n", This
, device
);
3260 WARN("Invalid argument supplied.\n");
3261 return D3DERR_INVALIDCALL
;
3264 IDirect3DDevice9_AddRef(This
->device
);
3266 *device
= This
->device
;
3268 TRACE("Returning device %p\n", *device
);
3273 static HRESULT WINAPI
ID3DXEffectImpl_OnLostDevice(ID3DXEffect
* iface
)
3275 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3277 FIXME("(%p)->(): stub\n", This
);
3282 static HRESULT WINAPI
ID3DXEffectImpl_OnResetDevice(ID3DXEffect
* iface
)
3284 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3286 FIXME("(%p)->(): stub\n", This
);
3291 static HRESULT WINAPI
ID3DXEffectImpl_SetStateManager(ID3DXEffect
*iface
, ID3DXEffectStateManager
*manager
)
3293 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3295 TRACE("iface %p, manager %p\n", This
, manager
);
3297 if (manager
) IUnknown_AddRef(manager
);
3298 if (This
->manager
) IUnknown_Release(This
->manager
);
3300 This
->manager
= manager
;
3305 static HRESULT WINAPI
ID3DXEffectImpl_GetStateManager(ID3DXEffect
*iface
, ID3DXEffectStateManager
**manager
)
3307 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3309 TRACE("iface %p, manager %p\n", This
, manager
);
3313 WARN("Invalid argument supplied.\n");
3314 return D3DERR_INVALIDCALL
;
3317 if (This
->manager
) IUnknown_AddRef(This
->manager
);
3318 *manager
= This
->manager
;
3323 static HRESULT WINAPI
ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect
* iface
)
3325 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3327 FIXME("(%p)->(): stub\n", This
);
3332 static D3DXHANDLE WINAPI
ID3DXEffectImpl_EndParameterBlock(ID3DXEffect
* iface
)
3334 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3336 FIXME("(%p)->(): stub\n", This
);
3341 static HRESULT WINAPI
ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect
* iface
, D3DXHANDLE parameter_block
)
3343 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3345 FIXME("(%p)->(%p): stub\n", This
, parameter_block
);
3350 static HRESULT WINAPI
ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect
* iface
, D3DXHANDLE parameter_block
)
3352 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3354 FIXME("(%p)->(%p): stub\n", This
, parameter_block
);
3359 static HRESULT WINAPI
ID3DXEffectImpl_CloneEffect(ID3DXEffect
*iface
,
3360 struct IDirect3DDevice9
*device
, struct ID3DXEffect
**effect
)
3362 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3364 FIXME("(%p)->(%p, %p): stub\n", This
, device
, effect
);
3369 static HRESULT WINAPI
ID3DXEffectImpl_SetRawValue(ID3DXEffect
*iface
,
3370 D3DXHANDLE parameter
, const void *data
, UINT byte_offset
, UINT bytes
)
3372 FIXME("iface %p, parameter %p, data %p, byte_offset %u, bytes %u stub!\n",
3373 iface
, parameter
, data
, byte_offset
, bytes
);
3378 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl
=
3380 /*** IUnknown methods ***/
3381 ID3DXEffectImpl_QueryInterface
,
3382 ID3DXEffectImpl_AddRef
,
3383 ID3DXEffectImpl_Release
,
3384 /*** ID3DXBaseEffect methods ***/
3385 ID3DXEffectImpl_GetDesc
,
3386 ID3DXEffectImpl_GetParameterDesc
,
3387 ID3DXEffectImpl_GetTechniqueDesc
,
3388 ID3DXEffectImpl_GetPassDesc
,
3389 ID3DXEffectImpl_GetFunctionDesc
,
3390 ID3DXEffectImpl_GetParameter
,
3391 ID3DXEffectImpl_GetParameterByName
,
3392 ID3DXEffectImpl_GetParameterBySemantic
,
3393 ID3DXEffectImpl_GetParameterElement
,
3394 ID3DXEffectImpl_GetTechnique
,
3395 ID3DXEffectImpl_GetTechniqueByName
,
3396 ID3DXEffectImpl_GetPass
,
3397 ID3DXEffectImpl_GetPassByName
,
3398 ID3DXEffectImpl_GetFunction
,
3399 ID3DXEffectImpl_GetFunctionByName
,
3400 ID3DXEffectImpl_GetAnnotation
,
3401 ID3DXEffectImpl_GetAnnotationByName
,
3402 ID3DXEffectImpl_SetValue
,
3403 ID3DXEffectImpl_GetValue
,
3404 ID3DXEffectImpl_SetBool
,
3405 ID3DXEffectImpl_GetBool
,
3406 ID3DXEffectImpl_SetBoolArray
,
3407 ID3DXEffectImpl_GetBoolArray
,
3408 ID3DXEffectImpl_SetInt
,
3409 ID3DXEffectImpl_GetInt
,
3410 ID3DXEffectImpl_SetIntArray
,
3411 ID3DXEffectImpl_GetIntArray
,
3412 ID3DXEffectImpl_SetFloat
,
3413 ID3DXEffectImpl_GetFloat
,
3414 ID3DXEffectImpl_SetFloatArray
,
3415 ID3DXEffectImpl_GetFloatArray
,
3416 ID3DXEffectImpl_SetVector
,
3417 ID3DXEffectImpl_GetVector
,
3418 ID3DXEffectImpl_SetVectorArray
,
3419 ID3DXEffectImpl_GetVectorArray
,
3420 ID3DXEffectImpl_SetMatrix
,
3421 ID3DXEffectImpl_GetMatrix
,
3422 ID3DXEffectImpl_SetMatrixArray
,
3423 ID3DXEffectImpl_GetMatrixArray
,
3424 ID3DXEffectImpl_SetMatrixPointerArray
,
3425 ID3DXEffectImpl_GetMatrixPointerArray
,
3426 ID3DXEffectImpl_SetMatrixTranspose
,
3427 ID3DXEffectImpl_GetMatrixTranspose
,
3428 ID3DXEffectImpl_SetMatrixTransposeArray
,
3429 ID3DXEffectImpl_GetMatrixTransposeArray
,
3430 ID3DXEffectImpl_SetMatrixTransposePointerArray
,
3431 ID3DXEffectImpl_GetMatrixTransposePointerArray
,
3432 ID3DXEffectImpl_SetString
,
3433 ID3DXEffectImpl_GetString
,
3434 ID3DXEffectImpl_SetTexture
,
3435 ID3DXEffectImpl_GetTexture
,
3436 ID3DXEffectImpl_GetPixelShader
,
3437 ID3DXEffectImpl_GetVertexShader
,
3438 ID3DXEffectImpl_SetArrayRange
,
3439 /*** ID3DXEffect methods ***/
3440 ID3DXEffectImpl_GetPool
,
3441 ID3DXEffectImpl_SetTechnique
,
3442 ID3DXEffectImpl_GetCurrentTechnique
,
3443 ID3DXEffectImpl_ValidateTechnique
,
3444 ID3DXEffectImpl_FindNextValidTechnique
,
3445 ID3DXEffectImpl_IsParameterUsed
,
3446 ID3DXEffectImpl_Begin
,
3447 ID3DXEffectImpl_BeginPass
,
3448 ID3DXEffectImpl_CommitChanges
,
3449 ID3DXEffectImpl_EndPass
,
3450 ID3DXEffectImpl_End
,
3451 ID3DXEffectImpl_GetDevice
,
3452 ID3DXEffectImpl_OnLostDevice
,
3453 ID3DXEffectImpl_OnResetDevice
,
3454 ID3DXEffectImpl_SetStateManager
,
3455 ID3DXEffectImpl_GetStateManager
,
3456 ID3DXEffectImpl_BeginParameterBlock
,
3457 ID3DXEffectImpl_EndParameterBlock
,
3458 ID3DXEffectImpl_ApplyParameterBlock
,
3459 ID3DXEffectImpl_DeleteParameterBlock
,
3460 ID3DXEffectImpl_CloneEffect
,
3461 ID3DXEffectImpl_SetRawValue
3464 static inline struct ID3DXEffectCompilerImpl
*impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler
*iface
)
3466 return CONTAINING_RECORD(iface
, struct ID3DXEffectCompilerImpl
, ID3DXEffectCompiler_iface
);
3469 /*** IUnknown methods ***/
3470 static HRESULT WINAPI
ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler
*iface
, REFIID riid
, void **object
)
3472 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), object
);
3474 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
3475 IsEqualGUID(riid
, &IID_ID3DXEffectCompiler
))
3477 iface
->lpVtbl
->AddRef(iface
);
3482 ERR("Interface %s not found\n", debugstr_guid(riid
));
3484 return E_NOINTERFACE
;
3487 static ULONG WINAPI
ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler
*iface
)
3489 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3491 TRACE("iface %p: AddRef from %u\n", iface
, This
->ref
);
3493 return InterlockedIncrement(&This
->ref
);
3496 static ULONG WINAPI
ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler
*iface
)
3498 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3499 ULONG ref
= InterlockedDecrement(&This
->ref
);
3501 TRACE("iface %p: Release from %u\n", iface
, ref
+ 1);
3505 free_effect_compiler(This
);
3506 HeapFree(GetProcessHeap(), 0, This
);
3512 /*** ID3DXBaseEffect methods ***/
3513 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler
*iface
, D3DXEFFECT_DESC
*desc
)
3515 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3517 TRACE("iface %p, desc %p.\n", iface
, desc
);
3519 return d3dx9_base_effect_get_desc(&compiler
->base_effect
, desc
);
3522 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler
*iface
,
3523 D3DXHANDLE parameter
, D3DXPARAMETER_DESC
*desc
)
3525 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3527 TRACE("iface %p, parameter %p, desc %p.\n", iface
, parameter
, desc
);
3529 return d3dx9_base_effect_get_parameter_desc(&compiler
->base_effect
, parameter
, desc
);
3532 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler
*iface
,
3533 D3DXHANDLE technique
, D3DXTECHNIQUE_DESC
*desc
)
3535 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3537 TRACE("iface %p, technique %p, desc %p.\n", iface
, technique
, desc
);
3539 return d3dx9_base_effect_get_technique_desc(&compiler
->base_effect
, technique
, desc
);
3542 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler
*iface
,
3543 D3DXHANDLE pass
, D3DXPASS_DESC
*desc
)
3545 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3547 TRACE("iface %p, pass %p, desc %p.\n", iface
, pass
, desc
);
3549 return d3dx9_base_effect_get_pass_desc(&compiler
->base_effect
, pass
, desc
);
3552 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler
*iface
,
3553 D3DXHANDLE shader
, D3DXFUNCTION_DESC
*desc
)
3555 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3557 TRACE("iface %p, shader %p, desc %p.\n", iface
, shader
, desc
);
3559 return d3dx9_base_effect_get_function_desc(&compiler
->base_effect
, shader
, desc
);
3562 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler
*iface
,
3563 D3DXHANDLE parameter
, UINT index
)
3565 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3567 TRACE("iface %p, parameter %p, index %u.\n", iface
, parameter
, index
);
3569 return d3dx9_base_effect_get_parameter(&compiler
->base_effect
, parameter
, index
);
3572 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler
*iface
,
3573 D3DXHANDLE parameter
, const char *name
)
3575 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3577 TRACE("iface %p, parameter %p, name %s.\n", iface
, parameter
, debugstr_a(name
));
3579 return d3dx9_base_effect_get_parameter_by_name(&compiler
->base_effect
, parameter
, name
);
3582 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler
*iface
,
3583 D3DXHANDLE parameter
, const char *semantic
)
3585 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3587 TRACE("iface %p, parameter %p, semantic %s.\n", iface
, parameter
, debugstr_a(semantic
));
3589 return d3dx9_base_effect_get_parameter_by_semantic(&compiler
->base_effect
, parameter
, semantic
);
3592 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler
*iface
,
3593 D3DXHANDLE parameter
, UINT index
)
3595 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3597 TRACE("iface %p, parameter %p, index %u.\n", iface
, parameter
, index
);
3599 return d3dx9_base_effect_get_parameter_element(&compiler
->base_effect
, parameter
, index
);
3602 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler
*iface
, UINT index
)
3604 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3606 TRACE("iface %p, index %u.\n", iface
, index
);
3608 return d3dx9_base_effect_get_technique(&compiler
->base_effect
, index
);
3611 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler
*iface
, const char *name
)
3613 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3615 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
3617 return d3dx9_base_effect_get_technique_by_name(&compiler
->base_effect
, name
);
3620 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler
*iface
, D3DXHANDLE technique
, UINT index
)
3622 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3624 TRACE("iface %p, technique %p, index %u.\n", iface
, technique
, index
);
3626 return d3dx9_base_effect_get_pass(&compiler
->base_effect
, technique
, index
);
3629 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler
*iface
,
3630 D3DXHANDLE technique
, const char *name
)
3632 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3634 TRACE("iface %p, technique %p, name %s.\n", iface
, technique
, debugstr_a(name
));
3636 return d3dx9_base_effect_get_pass_by_name(&compiler
->base_effect
, technique
, name
);
3639 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler
*iface
, UINT index
)
3641 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3643 TRACE("iface %p, index %u.\n", iface
, index
);
3645 return d3dx9_base_effect_get_function(&compiler
->base_effect
, index
);
3648 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler
*iface
, const char *name
)
3650 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3652 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
3654 return d3dx9_base_effect_get_function_by_name(&compiler
->base_effect
, name
);
3657 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler
*iface
,
3658 D3DXHANDLE object
, UINT index
)
3660 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3662 TRACE("iface %p, object %p, index %u.\n", iface
, object
, index
);
3664 return d3dx9_base_effect_get_annotation(&compiler
->base_effect
, object
, index
);
3667 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler
*iface
,
3668 D3DXHANDLE object
, const char *name
)
3670 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3672 TRACE("iface %p, object %p, name %s.\n", iface
, object
, debugstr_a(name
));
3674 return d3dx9_base_effect_get_annotation_by_name(&compiler
->base_effect
, object
, name
);
3677 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler
*iface
,
3678 D3DXHANDLE parameter
, const void *data
, UINT bytes
)
3680 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3682 TRACE("iface %p, parameter %p, data %p, bytes %u.\n", iface
, parameter
, data
, bytes
);
3684 return d3dx9_base_effect_set_value(&compiler
->base_effect
, parameter
, data
, bytes
);
3687 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler
*iface
,
3688 D3DXHANDLE parameter
, void *data
, UINT bytes
)
3690 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3692 TRACE("iface %p, parameter %p, data %p, bytes %u.\n", iface
, parameter
, data
, bytes
);
3694 return d3dx9_base_effect_get_value(&compiler
->base_effect
, parameter
, data
, bytes
);
3697 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL b
)
3699 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3701 TRACE("iface %p, parameter %p, b %#x.\n", iface
, parameter
, b
);
3703 return d3dx9_base_effect_set_bool(&compiler
->base_effect
, parameter
, b
);
3706 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL
*b
)
3708 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3710 TRACE("iface %p, parameter %p, b %p.\n", iface
, parameter
, b
);
3712 return d3dx9_base_effect_get_bool(&compiler
->base_effect
, parameter
, b
);
3715 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler
*iface
,
3716 D3DXHANDLE parameter
, const BOOL
*b
, UINT count
)
3718 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3720 TRACE("iface %p, parameter %p, b %p, count %u.\n", iface
, parameter
, b
, count
);
3722 return d3dx9_base_effect_set_bool_array(&compiler
->base_effect
, parameter
, b
, count
);
3725 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler
*iface
,
3726 D3DXHANDLE parameter
, BOOL
*b
, UINT count
)
3728 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3730 TRACE("iface %p, parameter %p, b %p, count %u.\n", iface
, parameter
, b
, count
);
3732 return d3dx9_base_effect_get_bool_array(&compiler
->base_effect
, parameter
, b
, count
);
3735 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, INT n
)
3737 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3739 TRACE("iface %p, parameter %p, n %d.\n", iface
, parameter
, n
);
3741 return d3dx9_base_effect_set_int(&compiler
->base_effect
, parameter
, n
);
3744 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, INT
*n
)
3746 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3748 TRACE("iface %p, parameter %p, n %p.\n", iface
, parameter
, n
);
3750 return d3dx9_base_effect_get_int(&compiler
->base_effect
, parameter
, n
);
3753 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler
*iface
,
3754 D3DXHANDLE parameter
, const INT
*n
, UINT count
)
3756 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3758 TRACE("iface %p, parameter %p, n %p, count %u.\n", iface
, parameter
, n
, count
);
3760 return d3dx9_base_effect_set_int_array(&compiler
->base_effect
, parameter
, n
, count
);
3763 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler
*iface
,
3764 D3DXHANDLE parameter
, INT
*n
, UINT count
)
3766 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3768 TRACE("iface %p, parameter %p, n %p, count %u.\n", iface
, parameter
, n
, count
);
3770 return d3dx9_base_effect_get_int_array(&compiler
->base_effect
, parameter
, n
, count
);
3773 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, float f
)
3775 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3777 TRACE("iface %p, parameter %p, f %.8e.\n", iface
, parameter
, f
);
3779 return d3dx9_base_effect_set_float(&compiler
->base_effect
, parameter
, f
);
3782 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, float *f
)
3784 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3786 TRACE("iface %p, parameter %p, f %p.\n", iface
, parameter
, f
);
3788 return d3dx9_base_effect_get_float(&compiler
->base_effect
, parameter
, f
);
3791 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler
*iface
,
3792 D3DXHANDLE parameter
, const float *f
, UINT count
)
3794 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3796 TRACE("iface %p, parameter %p, f %p, count %u.\n", iface
, parameter
, f
, count
);
3798 return d3dx9_base_effect_set_float_array(&compiler
->base_effect
, parameter
, f
, count
);
3801 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler
*iface
,
3802 D3DXHANDLE parameter
, float *f
, UINT count
)
3804 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3806 TRACE("iface %p, parameter %p, f %p, count %u.\n", iface
, parameter
, f
, count
);
3808 return d3dx9_base_effect_get_float_array(&compiler
->base_effect
, parameter
, f
, count
);
3811 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler
*iface
,
3812 D3DXHANDLE parameter
, const D3DXVECTOR4
*vector
)
3814 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3816 TRACE("iface %p, parameter %p, vector %p.\n", iface
, parameter
, vector
);
3818 return d3dx9_base_effect_set_vector(&compiler
->base_effect
, parameter
, vector
);
3821 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler
*iface
,
3822 D3DXHANDLE parameter
, D3DXVECTOR4
*vector
)
3824 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3826 TRACE("iface %p, parameter %p, vector %p.\n", iface
, parameter
, vector
);
3828 return d3dx9_base_effect_get_vector(&compiler
->base_effect
, parameter
, vector
);
3831 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler
*iface
,
3832 D3DXHANDLE parameter
, const D3DXVECTOR4
*vector
, UINT count
)
3834 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3836 TRACE("iface %p, parameter %p, vector %p, count %u.\n", iface
, parameter
, vector
, count
);
3838 return d3dx9_base_effect_set_vector_array(&compiler
->base_effect
, parameter
, vector
, count
);
3841 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler
*iface
,
3842 D3DXHANDLE parameter
, D3DXVECTOR4
*vector
, UINT count
)
3844 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3846 TRACE("iface %p, parameter %p, vector %p, count %u.\n", iface
, parameter
, vector
, count
);
3848 return d3dx9_base_effect_get_vector_array(&compiler
->base_effect
, parameter
, vector
, count
);
3851 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler
*iface
,
3852 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
)
3854 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3856 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
3858 return d3dx9_base_effect_set_matrix(&compiler
->base_effect
, parameter
, matrix
);
3861 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler
*iface
,
3862 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
3864 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3866 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
3868 return d3dx9_base_effect_get_matrix(&compiler
->base_effect
, parameter
, matrix
);
3871 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler
*iface
,
3872 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
, UINT count
)
3874 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3876 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3878 return d3dx9_base_effect_set_matrix_array(&compiler
->base_effect
, parameter
, matrix
, count
);
3881 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler
*iface
,
3882 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
3884 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3886 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3888 return d3dx9_base_effect_get_matrix_array(&compiler
->base_effect
, parameter
, matrix
, count
);
3891 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler
*iface
,
3892 D3DXHANDLE parameter
, const D3DXMATRIX
**matrix
, UINT count
)
3894 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3896 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3898 return d3dx9_base_effect_set_matrix_pointer_array(&compiler
->base_effect
, parameter
, matrix
, count
);
3901 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler
*iface
,
3902 D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
3904 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3906 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3908 return d3dx9_base_effect_get_matrix_pointer_array(&compiler
->base_effect
, parameter
, matrix
, count
);
3911 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler
*iface
,
3912 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
)
3914 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3916 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
3918 return d3dx9_base_effect_set_matrix_transpose(&compiler
->base_effect
, parameter
, matrix
);
3921 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler
*iface
,
3922 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
3924 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3926 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
3928 return d3dx9_base_effect_get_matrix_transpose(&compiler
->base_effect
, parameter
, matrix
);
3931 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler
*iface
,
3932 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
, UINT count
)
3934 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3936 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3938 return d3dx9_base_effect_set_matrix_transpose_array(&compiler
->base_effect
, parameter
, matrix
, count
);
3941 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler
*iface
,
3942 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
3944 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3946 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3948 return d3dx9_base_effect_get_matrix_transpose_array(&compiler
->base_effect
, parameter
, matrix
, count
);
3951 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler
*iface
,
3952 D3DXHANDLE parameter
, const D3DXMATRIX
**matrix
, UINT count
)
3954 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3956 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3958 return d3dx9_base_effect_set_matrix_transpose_pointer_array(&compiler
->base_effect
, parameter
, matrix
, count
);
3961 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler
*iface
,
3962 D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
3964 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3966 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3968 return d3dx9_base_effect_get_matrix_transpose_pointer_array(&compiler
->base_effect
, parameter
, matrix
, count
);
3971 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler
*iface
,
3972 D3DXHANDLE parameter
, const char *string
)
3974 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3976 TRACE("iface %p, parameter %p, string %s.\n", iface
, parameter
, debugstr_a(string
));
3978 return d3dx9_base_effect_set_string(&compiler
->base_effect
, parameter
, string
);
3981 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler
*iface
,
3982 D3DXHANDLE parameter
, const char **string
)
3984 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3986 TRACE("iface %p, parameter %p, string %p.\n", iface
, parameter
, string
);
3988 return d3dx9_base_effect_get_string(&compiler
->base_effect
, parameter
, string
);
3991 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetTexture(struct ID3DXEffectCompiler
*iface
,
3992 D3DXHANDLE parameter
, struct IDirect3DBaseTexture9
*texture
)
3994 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3996 TRACE("iface %p, parameter %p, texture %p.\n", iface
, parameter
, texture
);
3998 return d3dx9_base_effect_set_texture(&compiler
->base_effect
, parameter
, texture
);
4001 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetTexture(struct ID3DXEffectCompiler
*iface
,
4002 D3DXHANDLE parameter
, struct IDirect3DBaseTexture9
**texture
)
4004 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4006 TRACE("iface %p, parameter %p, texture %p.\n", iface
, parameter
, texture
);
4008 return d3dx9_base_effect_get_texture(&compiler
->base_effect
, parameter
, texture
);
4011 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler
*iface
,
4012 D3DXHANDLE parameter
, struct IDirect3DPixelShader9
**shader
)
4014 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4016 TRACE("iface %p, parameter %p, shader %p.\n", iface
, parameter
, shader
);
4018 return d3dx9_base_effect_get_pixel_shader(&compiler
->base_effect
, parameter
, shader
);
4021 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetVertexShader(struct ID3DXEffectCompiler
*iface
,
4022 D3DXHANDLE parameter
, struct IDirect3DVertexShader9
**shader
)
4024 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4026 TRACE("iface %p, parameter %p, shader %p.\n", iface
, parameter
, shader
);
4028 return d3dx9_base_effect_get_vertex_shader(&compiler
->base_effect
, parameter
, shader
);
4031 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler
*iface
,
4032 D3DXHANDLE parameter
, UINT start
, UINT end
)
4034 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4036 TRACE("iface %p, parameter %p, start %u, end %u.\n", iface
, parameter
, start
, end
);
4038 return d3dx9_base_effect_set_array_range(&compiler
->base_effect
, parameter
, start
, end
);
4041 /*** ID3DXEffectCompiler methods ***/
4042 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL literal
)
4044 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4046 FIXME("iface %p, parameter %p, literal %u\n", This
, parameter
, literal
);
4051 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL
*literal
)
4053 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4055 FIXME("iface %p, parameter %p, literal %p\n", This
, parameter
, literal
);
4060 static HRESULT WINAPI
ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler
*iface
, DWORD flags
,
4061 ID3DXBuffer
**effect
, ID3DXBuffer
**error_msgs
)
4063 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4065 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This
, flags
, effect
, error_msgs
);
4070 static HRESULT WINAPI
ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler
*iface
, D3DXHANDLE function
,
4071 const char *target
, DWORD flags
, ID3DXBuffer
**shader
, ID3DXBuffer
**error_msgs
,
4072 ID3DXConstantTable
**constant_table
)
4074 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4076 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
4077 This
, function
, target
, flags
, shader
, error_msgs
, constant_table
);
4082 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl
=
4084 /*** IUnknown methods ***/
4085 ID3DXEffectCompilerImpl_QueryInterface
,
4086 ID3DXEffectCompilerImpl_AddRef
,
4087 ID3DXEffectCompilerImpl_Release
,
4088 /*** ID3DXBaseEffect methods ***/
4089 ID3DXEffectCompilerImpl_GetDesc
,
4090 ID3DXEffectCompilerImpl_GetParameterDesc
,
4091 ID3DXEffectCompilerImpl_GetTechniqueDesc
,
4092 ID3DXEffectCompilerImpl_GetPassDesc
,
4093 ID3DXEffectCompilerImpl_GetFunctionDesc
,
4094 ID3DXEffectCompilerImpl_GetParameter
,
4095 ID3DXEffectCompilerImpl_GetParameterByName
,
4096 ID3DXEffectCompilerImpl_GetParameterBySemantic
,
4097 ID3DXEffectCompilerImpl_GetParameterElement
,
4098 ID3DXEffectCompilerImpl_GetTechnique
,
4099 ID3DXEffectCompilerImpl_GetTechniqueByName
,
4100 ID3DXEffectCompilerImpl_GetPass
,
4101 ID3DXEffectCompilerImpl_GetPassByName
,
4102 ID3DXEffectCompilerImpl_GetFunction
,
4103 ID3DXEffectCompilerImpl_GetFunctionByName
,
4104 ID3DXEffectCompilerImpl_GetAnnotation
,
4105 ID3DXEffectCompilerImpl_GetAnnotationByName
,
4106 ID3DXEffectCompilerImpl_SetValue
,
4107 ID3DXEffectCompilerImpl_GetValue
,
4108 ID3DXEffectCompilerImpl_SetBool
,
4109 ID3DXEffectCompilerImpl_GetBool
,
4110 ID3DXEffectCompilerImpl_SetBoolArray
,
4111 ID3DXEffectCompilerImpl_GetBoolArray
,
4112 ID3DXEffectCompilerImpl_SetInt
,
4113 ID3DXEffectCompilerImpl_GetInt
,
4114 ID3DXEffectCompilerImpl_SetIntArray
,
4115 ID3DXEffectCompilerImpl_GetIntArray
,
4116 ID3DXEffectCompilerImpl_SetFloat
,
4117 ID3DXEffectCompilerImpl_GetFloat
,
4118 ID3DXEffectCompilerImpl_SetFloatArray
,
4119 ID3DXEffectCompilerImpl_GetFloatArray
,
4120 ID3DXEffectCompilerImpl_SetVector
,
4121 ID3DXEffectCompilerImpl_GetVector
,
4122 ID3DXEffectCompilerImpl_SetVectorArray
,
4123 ID3DXEffectCompilerImpl_GetVectorArray
,
4124 ID3DXEffectCompilerImpl_SetMatrix
,
4125 ID3DXEffectCompilerImpl_GetMatrix
,
4126 ID3DXEffectCompilerImpl_SetMatrixArray
,
4127 ID3DXEffectCompilerImpl_GetMatrixArray
,
4128 ID3DXEffectCompilerImpl_SetMatrixPointerArray
,
4129 ID3DXEffectCompilerImpl_GetMatrixPointerArray
,
4130 ID3DXEffectCompilerImpl_SetMatrixTranspose
,
4131 ID3DXEffectCompilerImpl_GetMatrixTranspose
,
4132 ID3DXEffectCompilerImpl_SetMatrixTransposeArray
,
4133 ID3DXEffectCompilerImpl_GetMatrixTransposeArray
,
4134 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray
,
4135 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray
,
4136 ID3DXEffectCompilerImpl_SetString
,
4137 ID3DXEffectCompilerImpl_GetString
,
4138 ID3DXEffectCompilerImpl_SetTexture
,
4139 ID3DXEffectCompilerImpl_GetTexture
,
4140 ID3DXEffectCompilerImpl_GetPixelShader
,
4141 ID3DXEffectCompilerImpl_GetVertexShader
,
4142 ID3DXEffectCompilerImpl_SetArrayRange
,
4143 /*** ID3DXEffectCompiler methods ***/
4144 ID3DXEffectCompilerImpl_SetLiteral
,
4145 ID3DXEffectCompilerImpl_GetLiteral
,
4146 ID3DXEffectCompilerImpl_CompileEffect
,
4147 ID3DXEffectCompilerImpl_CompileShader
,
4150 static HRESULT
d3dx9_parse_sampler(struct d3dx9_base_effect
*base
, struct d3dx_sampler
*sampler
,
4151 const char *data
, const char **ptr
, struct d3dx_object
*objects
)
4156 read_dword(ptr
, &sampler
->state_count
);
4157 TRACE("Count: %u\n", sampler
->state_count
);
4159 sampler
->states
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*sampler
->states
) * sampler
->state_count
);
4160 if (!sampler
->states
)
4162 ERR("Out of memory\n");
4163 return E_OUTOFMEMORY
;
4166 for (i
= 0; i
< sampler
->state_count
; ++i
)
4168 hr
= d3dx9_parse_state(base
, &sampler
->states
[i
], data
, ptr
, objects
);
4171 WARN("Failed to parse state %u\n", i
);
4180 for (i
= 0; i
< sampler
->state_count
; ++i
)
4182 free_state(&sampler
->states
[i
]);
4184 HeapFree(GetProcessHeap(), 0, sampler
->states
);
4185 sampler
->states
= NULL
;
4190 static HRESULT
d3dx9_parse_value(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*param
,
4191 void *value
, const char *data
, const char **ptr
, struct d3dx_object
*objects
)
4197 if (param
->element_count
)
4199 param
->data
= value
;
4201 for (i
= 0; i
< param
->element_count
; ++i
)
4203 struct d3dx_parameter
*member
= ¶m
->members
[i
];
4205 hr
= d3dx9_parse_value(base
, member
, value
? (char *)value
+ old_size
: NULL
, data
, ptr
, objects
);
4208 WARN("Failed to parse value %u\n", i
);
4212 old_size
+= member
->bytes
;
4218 switch(param
->class)
4222 case D3DXPC_MATRIX_ROWS
:
4223 case D3DXPC_MATRIX_COLUMNS
:
4224 param
->data
= value
;
4228 param
->data
= value
;
4230 for (i
= 0; i
< param
->member_count
; ++i
)
4232 struct d3dx_parameter
*member
= ¶m
->members
[i
];
4234 hr
= d3dx9_parse_value(base
, member
, (char *)value
+ old_size
, data
, ptr
, objects
);
4237 WARN("Failed to parse value %u\n", i
);
4241 old_size
+= member
->bytes
;
4246 switch (param
->type
)
4249 case D3DXPT_TEXTURE
:
4250 case D3DXPT_TEXTURE1D
:
4251 case D3DXPT_TEXTURE2D
:
4252 case D3DXPT_TEXTURE3D
:
4253 case D3DXPT_TEXTURECUBE
:
4254 case D3DXPT_PIXELSHADER
:
4255 case D3DXPT_VERTEXSHADER
:
4256 read_dword(ptr
, ¶m
->object_id
);
4257 TRACE("Id: %u\n", param
->object_id
);
4258 objects
[param
->object_id
].param
= param
;
4259 param
->data
= value
;
4262 case D3DXPT_SAMPLER
:
4263 case D3DXPT_SAMPLER1D
:
4264 case D3DXPT_SAMPLER2D
:
4265 case D3DXPT_SAMPLER3D
:
4266 case D3DXPT_SAMPLERCUBE
:
4268 struct d3dx_sampler
*sampler
;
4270 sampler
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*sampler
));
4272 return E_OUTOFMEMORY
;
4274 hr
= d3dx9_parse_sampler(base
, sampler
, data
, ptr
, objects
);
4277 HeapFree(GetProcessHeap(), 0, sampler
);
4278 WARN("Failed to parse sampler\n");
4282 param
->data
= sampler
;
4287 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
4293 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
4300 static HRESULT
d3dx9_parse_init_value(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*param
,
4301 const char *data
, const char *ptr
, struct d3dx_object
*objects
)
4303 UINT size
= param
->bytes
;
4307 TRACE("param size: %u\n", size
);
4311 value
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
4314 ERR("Failed to allocate data memory.\n");
4315 return E_OUTOFMEMORY
;
4318 switch(param
->class)
4325 case D3DXPC_MATRIX_ROWS
:
4326 case D3DXPC_MATRIX_COLUMNS
:
4328 TRACE("Data: %s.\n", debugstr_an(ptr
, size
));
4329 memcpy(value
, ptr
, size
);
4333 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
4338 hr
= d3dx9_parse_value(base
, param
, value
, data
, &ptr
, objects
);
4341 WARN("Failed to parse value\n");
4342 HeapFree(GetProcessHeap(), 0, value
);
4349 static HRESULT
d3dx9_parse_name(char **name
, const char *ptr
)
4353 read_dword(&ptr
, &size
);
4354 TRACE("Name size: %#x\n", size
);
4361 *name
= HeapAlloc(GetProcessHeap(), 0, size
);
4364 ERR("Failed to allocate name memory.\n");
4365 return E_OUTOFMEMORY
;
4368 TRACE("Name: %s.\n", debugstr_an(ptr
, size
));
4369 memcpy(*name
, ptr
, size
);
4374 static HRESULT
d3dx9_copy_data(struct d3dx_object
*object
, const char **ptr
)
4376 if (object
->size
|| object
->data
)
4377 FIXME("Object already initialized!\n");
4379 read_dword(ptr
, &object
->size
);
4380 TRACE("Data size: %#x\n", object
->size
);
4385 object
->data
= HeapAlloc(GetProcessHeap(), 0, object
->size
);
4388 ERR("Failed to allocate object memory.\n");
4389 return E_OUTOFMEMORY
;
4392 TRACE("Data: %s.\n", debugstr_an(*ptr
, object
->size
));
4393 memcpy(object
->data
, *ptr
, object
->size
);
4395 *ptr
+= ((object
->size
+ 3) & ~3);
4400 static void add_param_to_table(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*param
)
4402 struct param_table
*table
= &base
->param_table
;
4404 if (table
->count
>= table
->size
)
4406 unsigned int new_size
;
4407 struct d3dx_parameter
**new_alloc
;
4411 new_size
= INITIAL_PARAM_TABLE_SIZE
;
4412 new_alloc
= HeapAlloc(GetProcessHeap(), 0, sizeof(*table
->table
) * new_size
);
4415 ERR("Out of memory.\n");
4421 new_size
= table
->size
* 2;
4422 new_alloc
= HeapReAlloc(GetProcessHeap(), 0, table
->table
, sizeof(*table
->table
) * new_size
);
4425 ERR("Out of memory.\n");
4429 table
->table
= new_alloc
;
4430 table
->size
= new_size
;
4433 table
->table
[table
->count
++] = param
;
4436 static void sync_param_handles(struct d3dx9_base_effect
*base
)
4438 struct param_table
*table
= &base
->param_table
;
4439 struct d3dx_parameter
**new_alloc
;
4444 new_alloc
= HeapReAlloc(GetProcessHeap(), 0, table
->table
, sizeof(*table
->table
) * table
->count
);
4446 table
->table
= new_alloc
;
4448 ERR("Out of memory.\n");
4451 for (i
= 0; i
< table
->count
; ++i
)
4452 table
->table
[i
]->handle
= (D3DXHANDLE
)&table
->table
[i
];
4455 static HRESULT
d3dx9_parse_effect_typedef(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*param
,
4456 const char *data
, const char **ptr
, struct d3dx_parameter
*parent
, UINT flags
)
4462 param
->flags
= flags
;
4466 read_dword(ptr
, (DWORD
*)¶m
->type
);
4467 TRACE("Type: %s\n", debug_d3dxparameter_type(param
->type
));
4469 read_dword(ptr
, (DWORD
*)¶m
->class);
4470 TRACE("Class: %s\n", debug_d3dxparameter_class(param
->class));
4472 read_dword(ptr
, &offset
);
4473 TRACE("Type name offset: %#x\n", offset
);
4474 hr
= d3dx9_parse_name(¶m
->name
, data
+ offset
);
4477 WARN("Failed to parse name\n");
4481 read_dword(ptr
, &offset
);
4482 TRACE("Type semantic offset: %#x\n", offset
);
4483 hr
= d3dx9_parse_name(¶m
->semantic
, data
+ offset
);
4486 WARN("Failed to parse semantic\n");
4490 read_dword(ptr
, ¶m
->element_count
);
4491 TRACE("Elements: %u\n", param
->element_count
);
4493 switch (param
->class)
4496 read_dword(ptr
, ¶m
->columns
);
4497 TRACE("Columns: %u\n", param
->columns
);
4499 read_dword(ptr
, ¶m
->rows
);
4500 TRACE("Rows: %u\n", param
->rows
);
4502 /* sizeof(DWORD) * rows * columns */
4503 param
->bytes
= 4 * param
->rows
* param
->columns
;
4507 case D3DXPC_MATRIX_ROWS
:
4508 case D3DXPC_MATRIX_COLUMNS
:
4509 read_dword(ptr
, ¶m
->rows
);
4510 TRACE("Rows: %u\n", param
->rows
);
4512 read_dword(ptr
, ¶m
->columns
);
4513 TRACE("Columns: %u\n", param
->columns
);
4515 /* sizeof(DWORD) * rows * columns */
4516 param
->bytes
= 4 * param
->rows
* param
->columns
;
4520 read_dword(ptr
, ¶m
->member_count
);
4521 TRACE("Members: %u\n", param
->member_count
);
4525 switch (param
->type
)
4528 case D3DXPT_PIXELSHADER
:
4529 case D3DXPT_VERTEXSHADER
:
4530 case D3DXPT_TEXTURE
:
4531 case D3DXPT_TEXTURE1D
:
4532 case D3DXPT_TEXTURE2D
:
4533 case D3DXPT_TEXTURE3D
:
4534 case D3DXPT_TEXTURECUBE
:
4535 param
->bytes
= sizeof(void *);
4538 case D3DXPT_SAMPLER
:
4539 case D3DXPT_SAMPLER1D
:
4540 case D3DXPT_SAMPLER2D
:
4541 case D3DXPT_SAMPLER3D
:
4542 case D3DXPT_SAMPLERCUBE
:
4547 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
4553 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
4560 param
->type
= parent
->type
;
4561 param
->class = parent
->class;
4562 param
->name
= parent
->name
;
4563 param
->semantic
= parent
->semantic
;
4564 param
->element_count
= 0;
4565 param
->annotation_count
= 0;
4566 param
->member_count
= parent
->member_count
;
4567 param
->bytes
= parent
->bytes
;
4568 param
->rows
= parent
->rows
;
4569 param
->columns
= parent
->columns
;
4572 if (param
->element_count
)
4574 unsigned int param_bytes
= 0;
4575 const char *save_ptr
= *ptr
;
4577 param
->members
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*param
->members
) * param
->element_count
);
4578 if (!param
->members
)
4580 ERR("Out of memory\n");
4585 for (i
= 0; i
< param
->element_count
; ++i
)
4589 add_param_to_table(base
, ¶m
->members
[i
]);
4590 hr
= d3dx9_parse_effect_typedef(base
, ¶m
->members
[i
], data
, ptr
, param
, flags
);
4593 WARN("Failed to parse member %u\n", i
);
4597 param_bytes
+= param
->members
[i
].bytes
;
4600 param
->bytes
= param_bytes
;
4602 else if (param
->member_count
)
4604 param
->members
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*param
->members
) * param
->member_count
);
4605 if (!param
->members
)
4607 ERR("Out of memory\n");
4612 for (i
= 0; i
< param
->member_count
; ++i
)
4614 add_param_to_table(base
, ¶m
->members
[i
]);
4615 hr
= d3dx9_parse_effect_typedef(base
, ¶m
->members
[i
], data
, ptr
, NULL
, flags
);
4618 WARN("Failed to parse member %u\n", i
);
4622 param
->bytes
+= param
->members
[i
].bytes
;
4631 unsigned int count
= param
->element_count
? param
->element_count
: param
->member_count
;
4633 for (i
= 0; i
< count
; ++i
)
4634 free_parameter(¶m
->members
[i
], param
->element_count
!= 0, TRUE
);
4635 HeapFree(GetProcessHeap(), 0, param
->members
);
4636 param
->members
= NULL
;
4641 HeapFree(GetProcessHeap(), 0, param
->name
);
4642 HeapFree(GetProcessHeap(), 0, param
->semantic
);
4645 param
->semantic
= NULL
;
4650 static HRESULT
d3dx9_parse_effect_annotation(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*anno
,
4651 const char *data
, const char **ptr
, struct d3dx_object
*objects
)
4657 anno
->flags
= D3DX_PARAMETER_ANNOTATION
;
4659 read_dword(ptr
, &offset
);
4660 TRACE("Typedef offset: %#x\n", offset
);
4661 ptr2
= data
+ offset
;
4662 hr
= d3dx9_parse_effect_typedef(base
, anno
, data
, &ptr2
, NULL
, D3DX_PARAMETER_ANNOTATION
);
4665 WARN("Failed to parse type definition\n");
4669 read_dword(ptr
, &offset
);
4670 TRACE("Value offset: %#x\n", offset
);
4671 hr
= d3dx9_parse_init_value(base
, anno
, data
, data
+ offset
, objects
);
4674 WARN("Failed to parse value\n");
4681 static HRESULT
d3dx9_parse_state(struct d3dx9_base_effect
*base
, struct d3dx_state
*state
,
4682 const char *data
, const char **ptr
, struct d3dx_object
*objects
)
4688 state
->type
= ST_CONSTANT
;
4690 read_dword(ptr
, &state
->operation
);
4691 TRACE("Operation: %#x (%s)\n", state
->operation
, state_table
[state
->operation
].name
);
4693 read_dword(ptr
, &state
->index
);
4694 TRACE("Index: %#x\n", state
->index
);
4696 read_dword(ptr
, &offset
);
4697 TRACE("Typedef offset: %#x\n", offset
);
4698 ptr2
= data
+ offset
;
4699 hr
= d3dx9_parse_effect_typedef(base
, &state
->parameter
, data
, &ptr2
, NULL
, 0);
4702 WARN("Failed to parse type definition\n");
4706 read_dword(ptr
, &offset
);
4707 TRACE("Value offset: %#x\n", offset
);
4708 hr
= d3dx9_parse_init_value(base
, &state
->parameter
, data
, data
+ offset
, objects
);
4711 WARN("Failed to parse value\n");
4719 free_parameter(&state
->parameter
, FALSE
, FALSE
);
4724 static HRESULT
d3dx9_parse_effect_parameter(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*param
,
4725 const char *data
, const char **ptr
, struct d3dx_object
*objects
)
4732 read_dword(ptr
, &offset
);
4733 TRACE("Typedef offset: %#x\n", offset
);
4734 ptr2
= data
+ offset
;
4736 read_dword(ptr
, &offset
);
4737 TRACE("Value offset: %#x\n", offset
);
4739 read_dword(ptr
, ¶m
->flags
);
4740 TRACE("Flags: %#x\n", param
->flags
);
4742 read_dword(ptr
, ¶m
->annotation_count
);
4743 TRACE("Annotation count: %u\n", param
->annotation_count
);
4745 hr
= d3dx9_parse_effect_typedef(base
, param
, data
, &ptr2
, NULL
, param
->flags
);
4748 WARN("Failed to parse type definition\n");
4752 hr
= d3dx9_parse_init_value(base
, param
, data
, data
+ offset
, objects
);
4755 WARN("Failed to parse value\n");
4759 if (param
->annotation_count
)
4761 param
->annotations
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
4762 sizeof(*param
->annotations
) * param
->annotation_count
);
4763 if (!param
->annotations
)
4765 ERR("Out of memory\n");
4770 for (i
= 0; i
< param
->annotation_count
; ++i
)
4772 add_param_to_table(base
, ¶m
->annotations
[i
]);
4773 hr
= d3dx9_parse_effect_annotation(base
, ¶m
->annotations
[i
], data
, ptr
, objects
);
4776 WARN("Failed to parse annotation\n");
4786 if (param
->annotations
)
4788 for (i
= 0; i
< param
->annotation_count
; ++i
)
4789 free_parameter(¶m
->annotations
[i
], FALSE
, FALSE
);
4790 HeapFree(GetProcessHeap(), 0, param
->annotations
);
4791 param
->annotations
= NULL
;
4797 static HRESULT
d3dx9_parse_effect_pass(struct d3dx9_base_effect
*base
, struct d3dx_pass
*pass
,
4798 const char *data
, const char **ptr
, struct d3dx_object
*objects
)
4803 struct d3dx_state
*states
= NULL
;
4806 read_dword(ptr
, &offset
);
4807 TRACE("Pass name offset: %#x\n", offset
);
4808 hr
= d3dx9_parse_name(&name
, data
+ offset
);
4811 WARN("Failed to parse name\n");
4815 read_dword(ptr
, &pass
->annotation_count
);
4816 TRACE("Annotation count: %u\n", pass
->annotation_count
);
4818 read_dword(ptr
, &pass
->state_count
);
4819 TRACE("State count: %u\n", pass
->state_count
);
4821 if (pass
->annotation_count
)
4823 pass
->annotations
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
4824 sizeof(*pass
->annotations
) * pass
->annotation_count
);
4825 if (!pass
->annotations
)
4827 ERR("Out of memory\n");
4832 for (i
= 0; i
< pass
->annotation_count
; ++i
)
4834 add_param_to_table(base
, &pass
->annotations
[i
]);
4835 hr
= d3dx9_parse_effect_annotation(base
, &pass
->annotations
[i
], data
, ptr
, objects
);
4838 WARN("Failed to parse annotation %u\n", i
);
4844 if (pass
->state_count
)
4846 states
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*states
) * pass
->state_count
);
4849 ERR("Out of memory\n");
4854 for (i
= 0; i
< pass
->state_count
; ++i
)
4856 hr
= d3dx9_parse_state(base
, &states
[i
], data
, ptr
, objects
);
4859 WARN("Failed to parse annotation %u\n", i
);
4866 pass
->states
= states
;
4872 if (pass
->annotations
)
4874 for (i
= 0; i
< pass
->annotation_count
; ++i
)
4875 free_parameter(&pass
->annotations
[i
], FALSE
, FALSE
);
4876 HeapFree(GetProcessHeap(), 0, pass
->annotations
);
4877 pass
->annotations
= NULL
;
4882 for (i
= 0; i
< pass
->state_count
; ++i
)
4884 free_state(&states
[i
]);
4886 HeapFree(GetProcessHeap(), 0, states
);
4889 HeapFree(GetProcessHeap(), 0, name
);
4894 static HRESULT
d3dx9_parse_effect_technique(struct d3dx9_base_effect
*base
, struct d3dx_technique
*technique
,
4895 const char *data
, const char **ptr
, struct d3dx_object
*objects
)
4902 read_dword(ptr
, &offset
);
4903 TRACE("Technique name offset: %#x\n", offset
);
4904 hr
= d3dx9_parse_name(&name
, data
+ offset
);
4907 WARN("Failed to parse name\n");
4911 read_dword(ptr
, &technique
->annotation_count
);
4912 TRACE("Annotation count: %u\n", technique
->annotation_count
);
4914 read_dword(ptr
, &technique
->pass_count
);
4915 TRACE("Pass count: %u\n", technique
->pass_count
);
4917 if (technique
->annotation_count
)
4919 technique
->annotations
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
4920 sizeof(*technique
->annotations
) * technique
->annotation_count
);
4921 if (!technique
->annotations
)
4923 ERR("Out of memory\n");
4928 for (i
= 0; i
< technique
->annotation_count
; ++i
)
4930 add_param_to_table(base
, &technique
->annotations
[i
]);
4931 hr
= d3dx9_parse_effect_annotation(base
, &technique
->annotations
[i
], data
, ptr
, objects
);
4934 WARN("Failed to parse annotation %u\n", i
);
4940 if (technique
->pass_count
)
4942 technique
->passes
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
4943 sizeof(*technique
->passes
) * technique
->pass_count
);
4944 if (!technique
->passes
)
4946 ERR("Out of memory\n");
4951 for (i
= 0; i
< technique
->pass_count
; ++i
)
4953 hr
= d3dx9_parse_effect_pass(base
, &technique
->passes
[i
], data
, ptr
, objects
);
4956 WARN("Failed to parse pass %u\n", i
);
4962 technique
->name
= name
;
4968 if (technique
->passes
)
4970 for (i
= 0; i
< technique
->pass_count
; ++i
)
4971 free_pass(&technique
->passes
[i
]);
4972 HeapFree(GetProcessHeap(), 0, technique
->passes
);
4973 technique
->passes
= NULL
;
4976 if (technique
->annotations
)
4978 for (i
= 0; i
< technique
->annotation_count
; ++i
)
4979 free_parameter(&technique
->annotations
[i
], FALSE
, FALSE
);
4980 HeapFree(GetProcessHeap(), 0, technique
->annotations
);
4981 technique
->annotations
= NULL
;
4984 HeapFree(GetProcessHeap(), 0, name
);
4989 static HRESULT
d3dx9_create_object(struct d3dx9_base_effect
*base
, struct d3dx_object
*object
)
4991 struct d3dx_parameter
*param
= object
->param
;
4992 struct IDirect3DDevice9
*device
= base
->effect
->device
;
4995 if (*(char **)param
->data
)
4996 ERR("Parameter data already allocated.\n");
4998 switch (param
->type
)
5001 *(char **)param
->data
= HeapAlloc(GetProcessHeap(), 0, object
->size
);
5002 if (!*(char **)param
->data
)
5004 ERR("Out of memory.\n");
5005 return E_OUTOFMEMORY
;
5007 memcpy(*(char **)param
->data
, object
->data
, object
->size
);
5009 case D3DXPT_VERTEXSHADER
:
5010 if (FAILED(hr
= IDirect3DDevice9_CreateVertexShader(device
, object
->data
,
5011 (IDirect3DVertexShader9
**)param
->data
)))
5013 WARN("Failed to create vertex shader.\n");
5017 case D3DXPT_PIXELSHADER
:
5018 if (FAILED(hr
= IDirect3DDevice9_CreatePixelShader(device
, object
->data
,
5019 (IDirect3DPixelShader9
**)param
->data
)))
5021 WARN("Failed to create pixel shader.\n");
5031 static HRESULT
d3dx9_parse_array_selector(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*param
)
5034 struct d3dx_object
*object
= &base
->objects
[param
->object_id
];
5035 char *ptr
= object
->data
;
5037 TRACE("Parsing array entry selection state for parameter %p.\n", param
);
5039 string_size
= *(DWORD
*)ptr
;
5040 param
->referenced_param
= get_parameter_by_name(base
, NULL
, ptr
+ 4);
5041 if (param
->referenced_param
)
5043 TRACE("Mapping to parameter %s.\n", debugstr_a(param
->referenced_param
->name
));
5047 FIXME("Referenced parameter %s not found.\n", ptr
+ 4);
5048 return D3DXERR_INVALIDDATA
;
5050 TRACE("Unknown DWORD: 0x%.8x.\n", *(DWORD
*)(ptr
+ string_size
));
5052 FIXME("Parse preshader.\n");
5057 static HRESULT
d3dx9_parse_resource(struct d3dx9_base_effect
*base
, const char *data
, const char **ptr
)
5059 DWORD technique_index
;
5060 DWORD index
, state_index
, usage
, element_index
;
5061 struct d3dx_state
*state
;
5062 struct d3dx_parameter
*param
;
5063 struct d3dx_object
*object
;
5064 HRESULT hr
= E_FAIL
;
5066 read_dword(ptr
, &technique_index
);
5067 TRACE("techn: %u\n", technique_index
);
5069 read_dword(ptr
, &index
);
5070 TRACE("index: %u\n", index
);
5072 read_dword(ptr
, &element_index
);
5073 TRACE("element_index: %u\n", element_index
);
5075 read_dword(ptr
, &state_index
);
5076 TRACE("state_index: %u\n", state_index
);
5078 read_dword(ptr
, &usage
);
5079 TRACE("usage: %u\n", usage
);
5081 if (technique_index
== 0xffffffff)
5083 struct d3dx_parameter
*parameter
;
5084 struct d3dx_sampler
*sampler
;
5086 if (index
>= base
->parameter_count
)
5088 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index
, base
->parameter_count
);
5092 parameter
= &base
->parameters
[index
];
5093 if (element_index
!= 0xffffffff)
5095 if (element_index
>= parameter
->element_count
&& parameter
->element_count
!= 0)
5097 FIXME("Index out of bounds: element_index %u >= element_count %u\n", element_index
, parameter
->element_count
);
5101 if (parameter
->element_count
!= 0) parameter
= ¶meter
->members
[element_index
];
5104 sampler
= parameter
->data
;
5105 if (state_index
>= sampler
->state_count
)
5107 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index
, sampler
->state_count
);
5111 state
= &sampler
->states
[state_index
];
5115 struct d3dx_technique
*technique
;
5116 struct d3dx_pass
*pass
;
5118 if (technique_index
>= base
->technique_count
)
5120 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index
, base
->technique_count
);
5124 technique
= &base
->techniques
[technique_index
];
5125 if (index
>= technique
->pass_count
)
5127 FIXME("Index out of bounds: index %u >= pass_count %u\n", index
, technique
->pass_count
);
5131 pass
= &technique
->passes
[index
];
5132 if (state_index
>= pass
->state_count
)
5134 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index
, pass
->state_count
);
5138 state
= &pass
->states
[state_index
];
5141 TRACE("State operation %#x (%s).\n", state
->operation
, state_table
[state
->operation
].name
);
5142 param
= &state
->parameter
;
5143 TRACE("Using object id %u.\n", param
->object_id
);
5144 object
= &base
->objects
[param
->object_id
];
5146 TRACE("Usage %u: class %s, type %s.\n", usage
, debug_d3dxparameter_class(param
->class),
5147 debug_d3dxparameter_type(param
->type
));
5151 switch (param
->type
)
5153 case D3DXPT_VERTEXSHADER
:
5154 case D3DXPT_PIXELSHADER
:
5155 state
->type
= ST_CONSTANT
;
5156 if (FAILED(hr
= d3dx9_copy_data(&base
->objects
[param
->object_id
], ptr
)))
5160 hr
= d3dx9_create_object(base
, object
);
5167 state
->type
= ST_FXLC
;
5168 hr
= d3dx9_copy_data(&base
->objects
[param
->object_id
], ptr
);
5172 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
5178 state
->type
= ST_PARAMETER
;
5179 if (FAILED(hr
= d3dx9_copy_data(&base
->objects
[param
->object_id
], ptr
)))
5182 TRACE("Looking for parameter %s.\n", debugstr_a(object
->data
));
5183 param
->referenced_param
= get_parameter_by_name(base
, NULL
, object
->data
);
5184 if (param
->referenced_param
)
5186 TRACE("Mapping to parameter %p.\n", param
->referenced_param
);
5190 FIXME("Referenced parameter %s not found.\n", (char *)object
->data
);
5191 return D3DXERR_INVALIDDATA
;
5196 state
->type
= ST_ARRAY_SELECTOR
;
5197 if (FAILED(hr
= d3dx9_copy_data(object
, ptr
)))
5199 hr
= d3dx9_parse_array_selector(base
, param
);
5203 FIXME("Unknown usage %x\n", usage
);
5210 static HRESULT
d3dx9_parse_effect(struct d3dx9_base_effect
*base
, const char *data
, UINT data_size
, DWORD start
)
5212 const char *ptr
= data
+ start
;
5213 UINT stringcount
, resourcecount
;
5217 read_dword(&ptr
, &base
->parameter_count
);
5218 TRACE("Parameter count: %u\n", base
->parameter_count
);
5220 read_dword(&ptr
, &base
->technique_count
);
5221 TRACE("Technique count: %u\n", base
->technique_count
);
5223 skip_dword_unknown(&ptr
, 1);
5225 read_dword(&ptr
, &base
->object_count
);
5226 TRACE("Object count: %u\n", base
->object_count
);
5228 base
->objects
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*base
->objects
) * base
->object_count
);
5231 ERR("Out of memory\n");
5236 if (base
->parameter_count
)
5238 base
->parameters
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
5239 sizeof(*base
->parameters
) * base
->parameter_count
);
5240 if (!base
->parameters
)
5242 ERR("Out of memory\n");
5247 for (i
= 0; i
< base
->parameter_count
; ++i
)
5249 add_param_to_table(base
, &base
->parameters
[i
]);
5250 hr
= d3dx9_parse_effect_parameter(base
, &base
->parameters
[i
], data
, &ptr
, base
->objects
);
5253 WARN("Failed to parse parameter %u\n", i
);
5259 if (base
->technique_count
)
5261 base
->techniques
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
5262 sizeof(*base
->techniques
) * base
->technique_count
);
5263 if (!base
->techniques
)
5265 ERR("Out of memory\n");
5270 for (i
= 0; i
< base
->technique_count
; ++i
)
5272 TRACE("Parsing technique %u.\n", i
);
5273 hr
= d3dx9_parse_effect_technique(base
, &base
->techniques
[i
], data
, &ptr
, base
->objects
);
5276 WARN("Failed to parse technique %u\n", i
);
5282 sync_param_handles(base
);
5284 read_dword(&ptr
, &stringcount
);
5285 TRACE("String count: %u\n", stringcount
);
5287 read_dword(&ptr
, &resourcecount
);
5288 TRACE("Resource count: %u\n", resourcecount
);
5290 for (i
= 0; i
< stringcount
; ++i
)
5294 read_dword(&ptr
, &id
);
5295 TRACE("Id: %u\n", id
);
5297 if (FAILED(hr
= d3dx9_copy_data(&base
->objects
[id
], &ptr
)))
5300 if (base
->objects
[id
].data
)
5302 if (FAILED(hr
= d3dx9_create_object(base
, &base
->objects
[id
])))
5307 for (i
= 0; i
< resourcecount
; ++i
)
5309 TRACE("parse resource %u\n", i
);
5311 hr
= d3dx9_parse_resource(base
, data
, &ptr
);
5314 WARN("Failed to parse resource %u\n", i
);
5323 if (base
->techniques
)
5325 for (i
= 0; i
< base
->technique_count
; ++i
)
5326 free_technique(&base
->techniques
[i
]);
5327 HeapFree(GetProcessHeap(), 0, base
->techniques
);
5328 base
->techniques
= NULL
;
5331 if (base
->parameters
)
5333 for (i
= 0; i
< base
->parameter_count
; ++i
)
5335 free_parameter(&base
->parameters
[i
], FALSE
, FALSE
);
5337 HeapFree(GetProcessHeap(), 0, base
->parameters
);
5338 base
->parameters
= NULL
;
5343 for (i
= 0; i
< base
->object_count
; ++i
)
5345 free_object(&base
->objects
[i
]);
5347 HeapFree(GetProcessHeap(), 0, base
->objects
);
5348 base
->objects
= NULL
;
5354 static HRESULT
d3dx9_base_effect_init(struct d3dx9_base_effect
*base
,
5355 const char *data
, SIZE_T data_size
, const D3D_SHADER_MACRO
*defines
, ID3DInclude
*include
,
5356 UINT eflags
, ID3DBlob
**errors
, struct ID3DXEffectImpl
*effect
)
5359 const char *ptr
= data
;
5361 ID3DBlob
*bytecode
= NULL
, *temp_errors
= NULL
;
5363 TRACE("base %p, data %p, data_size %lu, effect %p\n", base
, data
, data_size
, effect
);
5365 base
->effect
= effect
;
5367 read_dword(&ptr
, &tag
);
5368 TRACE("Tag: %x\n", tag
);
5370 if (tag
!= d3dx9_effect_version(9, 1))
5372 TRACE("HLSL ASCII effect, trying to compile it.\n");
5373 hr
= D3DCompile(data
, data_size
, NULL
, defines
, include
,
5374 "main", "fx_2_0", 0, eflags
, &bytecode
, &temp_errors
);
5377 WARN("Failed to compile ASCII effect.\n");
5379 ID3D10Blob_Release(bytecode
);
5381 TRACE("%s\n", (char *)ID3D10Blob_GetBufferPointer(temp_errors
));
5383 *errors
= temp_errors
;
5384 else if (temp_errors
)
5385 ID3D10Blob_Release(temp_errors
);
5390 FIXME("No output from effect compilation.\n");
5391 return D3DERR_INVALIDCALL
;
5394 *errors
= temp_errors
;
5395 else if (temp_errors
)
5396 ID3D10Blob_Release(temp_errors
);
5398 ptr
= ID3D10Blob_GetBufferPointer(bytecode
);
5399 read_dword(&ptr
, &tag
);
5400 TRACE("Tag: %x\n", tag
);
5403 read_dword(&ptr
, &offset
);
5404 TRACE("Offset: %x\n", offset
);
5406 hr
= d3dx9_parse_effect(base
, ptr
, data_size
, offset
);
5408 ID3D10Blob_Release(bytecode
);
5411 FIXME("Failed to parse effect.\n");
5418 static HRESULT
d3dx9_effect_init(struct ID3DXEffectImpl
*effect
, struct IDirect3DDevice9
*device
,
5419 const char *data
, SIZE_T data_size
, const D3D_SHADER_MACRO
*defines
, ID3DInclude
*include
,
5420 UINT eflags
, ID3DBlob
**error_messages
, struct ID3DXEffectPool
*pool
)
5424 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect
, device
, data
, data_size
, pool
);
5426 effect
->ID3DXEffect_iface
.lpVtbl
= &ID3DXEffect_Vtbl
;
5429 if (pool
) pool
->lpVtbl
->AddRef(pool
);
5430 effect
->pool
= pool
;
5432 IDirect3DDevice9_AddRef(device
);
5433 effect
->device
= device
;
5435 if (FAILED(hr
= d3dx9_base_effect_init(&effect
->base_effect
, data
, data_size
, defines
, include
,
5436 eflags
, error_messages
, effect
)))
5438 FIXME("Failed to parse effect, hr %#x.\n", hr
);
5439 free_effect(effect
);
5443 /* initialize defaults - check because of unsupported ascii effects */
5444 if (effect
->base_effect
.techniques
)
5446 effect
->active_technique
= &effect
->base_effect
.techniques
[0];
5447 effect
->active_pass
= NULL
;
5453 HRESULT WINAPI
D3DXCreateEffectEx(struct IDirect3DDevice9
*device
, const void *srcdata
, UINT srcdatalen
,
5454 const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, const char *skip_constants
, DWORD flags
,
5455 struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilation_errors
)
5457 struct ID3DXEffectImpl
*object
;
5460 TRACE("device %p, srcdata %p, srcdatalen %u, defines %p, include %p,"
5461 " skip_constants %p, flags %#x, pool %p, effect %p, compilation_errors %p.\n",
5462 device
, srcdata
, srcdatalen
, defines
, include
,
5463 skip_constants
, flags
, pool
, effect
, compilation_errors
);
5465 if (compilation_errors
)
5466 *compilation_errors
= NULL
;
5468 if (!device
|| !srcdata
)
5469 return D3DERR_INVALIDCALL
;
5474 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5479 FIXME("skip_constants is not NULL, not supported yet.\n");
5481 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
5483 return E_OUTOFMEMORY
;
5485 hr
= d3dx9_effect_init(object
, device
, srcdata
, srcdatalen
, (const D3D_SHADER_MACRO
*)defines
,
5486 (ID3DInclude
*)include
, flags
, (ID3DBlob
**)compilation_errors
, pool
);
5489 WARN("Failed to create effect object.\n");
5490 HeapFree(GetProcessHeap(), 0, object
);
5494 *effect
= &object
->ID3DXEffect_iface
;
5496 TRACE("Created ID3DXEffect %p\n", object
);
5501 HRESULT WINAPI
D3DXCreateEffect(struct IDirect3DDevice9
*device
, const void *srcdata
, UINT srcdatalen
,
5502 const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, DWORD flags
,
5503 struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilation_errors
)
5505 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device
, srcdata
, srcdatalen
, defines
,
5506 include
, flags
, pool
, effect
, compilation_errors
);
5508 return D3DXCreateEffectEx(device
, srcdata
, srcdatalen
, defines
, include
, NULL
, flags
, pool
, effect
, compilation_errors
);
5511 static HRESULT
d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl
*compiler
,
5512 const char *data
, SIZE_T data_size
, const D3D_SHADER_MACRO
*defines
, ID3DInclude
*include
,
5513 UINT eflags
, ID3DBlob
**error_messages
)
5517 TRACE("effect %p, data %p, data_size %lu\n", compiler
, data
, data_size
);
5519 compiler
->ID3DXEffectCompiler_iface
.lpVtbl
= &ID3DXEffectCompiler_Vtbl
;
5522 if (FAILED(hr
= d3dx9_base_effect_init(&compiler
->base_effect
, data
, data_size
, defines
,
5523 include
, eflags
, error_messages
, NULL
)))
5525 FIXME("Failed to parse effect, hr %#x.\n", hr
);
5526 free_effect_compiler(compiler
);
5533 HRESULT WINAPI
D3DXCreateEffectCompiler(const char *srcdata
, UINT srcdatalen
, const D3DXMACRO
*defines
,
5534 ID3DXInclude
*include
, DWORD flags
, ID3DXEffectCompiler
**compiler
, ID3DXBuffer
**parse_errors
)
5536 struct ID3DXEffectCompilerImpl
*object
;
5539 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5540 srcdata
, srcdatalen
, defines
, include
, flags
, compiler
, parse_errors
);
5542 if (!srcdata
|| !compiler
)
5544 WARN("Invalid arguments supplied\n");
5545 return D3DERR_INVALIDCALL
;
5548 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
5550 return E_OUTOFMEMORY
;
5552 hr
= d3dx9_effect_compiler_init(object
, srcdata
, srcdatalen
, (const D3D_SHADER_MACRO
*)defines
,
5553 (ID3DInclude
*)include
, flags
, (ID3DBlob
**)parse_errors
);
5556 WARN("Failed to initialize effect compiler\n");
5557 HeapFree(GetProcessHeap(), 0, object
);
5561 *compiler
= &object
->ID3DXEffectCompiler_iface
;
5563 TRACE("Created ID3DXEffectCompiler %p\n", object
);
5568 struct ID3DXEffectPoolImpl
5570 ID3DXEffectPool ID3DXEffectPool_iface
;
5574 static inline struct ID3DXEffectPoolImpl
*impl_from_ID3DXEffectPool(ID3DXEffectPool
*iface
)
5576 return CONTAINING_RECORD(iface
, struct ID3DXEffectPoolImpl
, ID3DXEffectPool_iface
);
5579 /*** IUnknown methods ***/
5580 static HRESULT WINAPI
ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool
*iface
, REFIID riid
, void **object
)
5582 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), object
);
5584 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
5585 IsEqualGUID(riid
, &IID_ID3DXEffectPool
))
5587 iface
->lpVtbl
->AddRef(iface
);
5592 WARN("Interface %s not found\n", debugstr_guid(riid
));
5594 return E_NOINTERFACE
;
5597 static ULONG WINAPI
ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool
*iface
)
5599 struct ID3DXEffectPoolImpl
*This
= impl_from_ID3DXEffectPool(iface
);
5601 TRACE("(%p)->(): AddRef from %u\n", This
, This
->ref
);
5603 return InterlockedIncrement(&This
->ref
);
5606 static ULONG WINAPI
ID3DXEffectPoolImpl_Release(ID3DXEffectPool
*iface
)
5608 struct ID3DXEffectPoolImpl
*This
= impl_from_ID3DXEffectPool(iface
);
5609 ULONG ref
= InterlockedDecrement(&This
->ref
);
5611 TRACE("(%p)->(): Release from %u\n", This
, ref
+ 1);
5614 HeapFree(GetProcessHeap(), 0, This
);
5619 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl
=
5621 /*** IUnknown methods ***/
5622 ID3DXEffectPoolImpl_QueryInterface
,
5623 ID3DXEffectPoolImpl_AddRef
,
5624 ID3DXEffectPoolImpl_Release
5627 HRESULT WINAPI
D3DXCreateEffectPool(ID3DXEffectPool
**pool
)
5629 struct ID3DXEffectPoolImpl
*object
;
5631 TRACE("(%p)\n", pool
);
5634 return D3DERR_INVALIDCALL
;
5636 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
5638 return E_OUTOFMEMORY
;
5640 object
->ID3DXEffectPool_iface
.lpVtbl
= &ID3DXEffectPool_Vtbl
;
5643 *pool
= &object
->ID3DXEffectPool_iface
;
5648 HRESULT WINAPI
D3DXCreateEffectFromFileExW(struct IDirect3DDevice9
*device
, const WCHAR
*srcfile
,
5649 const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, const char *skipconstants
, DWORD flags
,
5650 struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
5656 TRACE("device %p, srcfile %s, defines %p, include %p, skipconstants %s, "
5657 "flags %#x, pool %p, effect %p, compilationerrors %p.\n",
5658 device
, debugstr_w(srcfile
), defines
, include
, debugstr_a(skipconstants
),
5659 flags
, pool
, effect
, compilationerrors
);
5661 if (!device
|| !srcfile
)
5662 return D3DERR_INVALIDCALL
;
5664 ret
= map_view_of_file(srcfile
, &buffer
, &size
);
5667 return D3DXERR_INVALIDDATA
;
5669 ret
= D3DXCreateEffectEx(device
, buffer
, size
, defines
, include
, skipconstants
, flags
, pool
, effect
, compilationerrors
);
5670 UnmapViewOfFile(buffer
);
5675 HRESULT WINAPI
D3DXCreateEffectFromFileExA(struct IDirect3DDevice9
*device
, const char *srcfile
,
5676 const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, const char *skipconstants
, DWORD flags
,
5677 struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
5683 TRACE("device %p, srcfile %s, defines %p, include %p, skipconstants %s, "
5684 "flags %#x, pool %p, effect %p, compilationerrors %p.\n",
5685 device
, debugstr_a(srcfile
), defines
, include
, debugstr_a(skipconstants
),
5686 flags
, pool
, effect
, compilationerrors
);
5689 return D3DERR_INVALIDCALL
;
5691 len
= MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, NULL
, 0);
5692 srcfileW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(*srcfileW
));
5693 MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, srcfileW
, len
);
5695 ret
= D3DXCreateEffectFromFileExW(device
, srcfileW
, defines
, include
, skipconstants
, flags
, pool
, effect
, compilationerrors
);
5696 HeapFree(GetProcessHeap(), 0, srcfileW
);
5701 HRESULT WINAPI
D3DXCreateEffectFromFileW(struct IDirect3DDevice9
*device
, const WCHAR
*srcfile
,
5702 const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, DWORD flags
, struct ID3DXEffectPool
*pool
,
5703 struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
5705 TRACE("(void): relay\n");
5706 return D3DXCreateEffectFromFileExW(device
, srcfile
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
5709 HRESULT WINAPI
D3DXCreateEffectFromFileA(struct IDirect3DDevice9
*device
, const char *srcfile
,
5710 const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, DWORD flags
, struct ID3DXEffectPool
*pool
,
5711 struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
5713 TRACE("(void): relay\n");
5714 return D3DXCreateEffectFromFileExA(device
, srcfile
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
5717 HRESULT WINAPI
D3DXCreateEffectFromResourceExW(struct IDirect3DDevice9
*device
, HMODULE srcmodule
,
5718 const WCHAR
*srcresource
, const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, const char *skipconstants
,
5719 DWORD flags
, struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
5725 TRACE("device %p, srcmodule %p, srcresource %s, defines %p, include %p, skipconstants %s, "
5726 "flags %#x, pool %p, effect %p, compilationerrors %p.\n",
5727 device
, srcmodule
, debugstr_w(srcresource
), defines
, include
, debugstr_a(skipconstants
),
5728 flags
, pool
, effect
, compilationerrors
);
5731 return D3DERR_INVALIDCALL
;
5733 if (!(resinfo
= FindResourceW(srcmodule
, srcresource
, (const WCHAR
*)RT_RCDATA
)))
5734 return D3DXERR_INVALIDDATA
;
5736 if (FAILED(load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
)))
5737 return D3DXERR_INVALIDDATA
;
5739 return D3DXCreateEffectEx(device
, buffer
, size
, defines
, include
,
5740 skipconstants
, flags
, pool
, effect
, compilationerrors
);
5743 HRESULT WINAPI
D3DXCreateEffectFromResourceExA(struct IDirect3DDevice9
*device
, HMODULE srcmodule
,
5744 const char *srcresource
, const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, const char *skipconstants
,
5745 DWORD flags
, struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
5751 TRACE("device %p, srcmodule %p, srcresource %s, defines %p, include %p, skipconstants %s, "
5752 "flags %#x, pool %p, effect %p, compilationerrors %p.\n",
5753 device
, srcmodule
, debugstr_a(srcresource
), defines
, include
, debugstr_a(skipconstants
),
5754 flags
, pool
, effect
, compilationerrors
);
5757 return D3DERR_INVALIDCALL
;
5759 if (!(resinfo
= FindResourceA(srcmodule
, srcresource
, (const char *)RT_RCDATA
)))
5760 return D3DXERR_INVALIDDATA
;
5762 if (FAILED(load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
)))
5763 return D3DXERR_INVALIDDATA
;
5765 return D3DXCreateEffectEx(device
, buffer
, size
, defines
, include
,
5766 skipconstants
, flags
, pool
, effect
, compilationerrors
);
5769 HRESULT WINAPI
D3DXCreateEffectFromResourceW(struct IDirect3DDevice9
*device
, HMODULE srcmodule
,
5770 const WCHAR
*srcresource
, const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, DWORD flags
,
5771 struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
5773 TRACE("(void): relay\n");
5774 return D3DXCreateEffectFromResourceExW(device
, srcmodule
, srcresource
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
5777 HRESULT WINAPI
D3DXCreateEffectFromResourceA(struct IDirect3DDevice9
*device
, HMODULE srcmodule
,
5778 const char *srcresource
, const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, DWORD flags
,
5779 struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
5781 TRACE("(void): relay\n");
5782 return D3DXCreateEffectFromResourceExA(device
, srcmodule
, srcresource
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
5785 HRESULT WINAPI
D3DXCreateEffectCompilerFromFileW(const WCHAR
*srcfile
, const D3DXMACRO
*defines
,
5786 ID3DXInclude
*include
, DWORD flags
, ID3DXEffectCompiler
**effectcompiler
, ID3DXBuffer
**parseerrors
)
5792 TRACE("srcfile %s, defines %p, include %p, flags %#x, effectcompiler %p, parseerrors %p.\n",
5793 debugstr_w(srcfile
), defines
, include
, flags
, effectcompiler
, parseerrors
);
5796 return D3DERR_INVALIDCALL
;
5798 ret
= map_view_of_file(srcfile
, &buffer
, &size
);
5801 return D3DXERR_INVALIDDATA
;
5803 ret
= D3DXCreateEffectCompiler(buffer
, size
, defines
, include
, flags
, effectcompiler
, parseerrors
);
5804 UnmapViewOfFile(buffer
);
5809 HRESULT WINAPI
D3DXCreateEffectCompilerFromFileA(const char *srcfile
, const D3DXMACRO
*defines
,
5810 ID3DXInclude
*include
, DWORD flags
, ID3DXEffectCompiler
**effectcompiler
, ID3DXBuffer
**parseerrors
)
5816 TRACE("srcfile %s, defines %p, include %p, flags %#x, effectcompiler %p, parseerrors %p.\n",
5817 debugstr_a(srcfile
), defines
, include
, flags
, effectcompiler
, parseerrors
);
5820 return D3DERR_INVALIDCALL
;
5822 len
= MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, NULL
, 0);
5823 srcfileW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(*srcfileW
));
5824 MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, srcfileW
, len
);
5826 ret
= D3DXCreateEffectCompilerFromFileW(srcfileW
, defines
, include
, flags
, effectcompiler
, parseerrors
);
5827 HeapFree(GetProcessHeap(), 0, srcfileW
);
5832 HRESULT WINAPI
D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule
, const char *srcresource
,
5833 const D3DXMACRO
*defines
, ID3DXInclude
*include
, DWORD flags
,
5834 ID3DXEffectCompiler
**effectcompiler
, ID3DXBuffer
**parseerrors
)
5840 TRACE("srcmodule %p, srcresource %s, defines %p, include %p, flags %#x, effectcompiler %p, parseerrors %p.\n",
5841 srcmodule
, debugstr_a(srcresource
), defines
, include
, flags
, effectcompiler
, parseerrors
);
5843 if (!(resinfo
= FindResourceA(srcmodule
, srcresource
, (const char *)RT_RCDATA
)))
5844 return D3DXERR_INVALIDDATA
;
5846 if (FAILED(load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
)))
5847 return D3DXERR_INVALIDDATA
;
5849 return D3DXCreateEffectCompiler(buffer
, size
, defines
, include
, flags
, effectcompiler
, parseerrors
);
5852 HRESULT WINAPI
D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule
, const WCHAR
*srcresource
,
5853 const D3DXMACRO
*defines
, ID3DXInclude
*include
, DWORD flags
,
5854 ID3DXEffectCompiler
**effectcompiler
, ID3DXBuffer
**parseerrors
)
5860 TRACE("srcmodule %p, srcresource %s, defines %p, include %p, flags %#x, effectcompiler %p, parseerrors %p.\n",
5861 srcmodule
, debugstr_w(srcresource
), defines
, include
, flags
, effectcompiler
, parseerrors
);
5863 if (!(resinfo
= FindResourceW(srcmodule
, srcresource
, (const WCHAR
*)RT_RCDATA
)))
5864 return D3DXERR_INVALIDDATA
;
5866 if (FAILED(load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
)))
5867 return D3DXERR_INVALIDDATA
;
5869 return D3DXCreateEffectCompiler(buffer
, size
, defines
, include
, flags
, effectcompiler
, parseerrors
);
5872 HRESULT WINAPI
D3DXDisassembleEffect(ID3DXEffect
*effect
, BOOL enable_color_code
, ID3DXBuffer
**disassembly
)
5874 FIXME("(%p, %u, %p): stub\n", effect
, enable_color_code
, disassembly
);
5876 return D3DXERR_INVALIDDATA
;