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"
23 #include "d3dx9_private.h"
24 #include "d3dcompiler.h"
26 /* Constants for special INT/FLOAT conversation */
27 #define INT_FLOAT_MULTI 255.0f
28 #define INT_FLOAT_MULTI_INVERSE (1/INT_FLOAT_MULTI)
30 #define INITIAL_PARAM_TABLE_SIZE 16
32 WINE_DEFAULT_DEBUG_CHANNEL(d3dx
);
79 enum SHADER_CONSTANT_TYPE
101 struct d3dx_parameter
*param
;
108 enum STATE_TYPE type
;
109 struct d3dx_parameter parameter
;
115 struct d3dx_state
*states
;
122 UINT annotation_count
;
124 struct d3dx_state
*states
;
125 struct d3dx_parameter
*annotations
;
128 struct d3dx_technique
132 UINT annotation_count
;
134 struct d3dx_parameter
*annotations
;
135 struct d3dx_pass
*passes
;
137 struct IDirect3DStateBlock9
*saved_state
;
142 struct d3dx_parameter
**table
;
143 unsigned int count
, size
;
146 struct d3dx9_base_effect
148 struct ID3DXEffectImpl
*effect
;
150 UINT parameter_count
;
151 UINT technique_count
;
154 struct d3dx_parameter
*parameters
;
155 struct d3dx_technique
*techniques
;
156 struct d3dx_object
*objects
;
158 struct param_table param_table
;
161 struct ID3DXEffectImpl
163 ID3DXEffect ID3DXEffect_iface
;
166 struct d3dx9_base_effect base_effect
;
168 struct ID3DXEffectStateManager
*manager
;
169 struct IDirect3DDevice9
*device
;
170 struct ID3DXEffectPool
*pool
;
171 struct d3dx_technique
*active_technique
;
172 struct d3dx_pass
*active_pass
;
177 struct ID3DXEffectCompilerImpl
179 ID3DXEffectCompiler ID3DXEffectCompiler_iface
;
182 struct d3dx9_base_effect base_effect
;
185 static struct d3dx_parameter
*get_annotation_by_name(UINT count
, struct d3dx_parameter
*parameters
,
187 static HRESULT
d3dx9_parse_state(struct d3dx9_base_effect
*base
, struct d3dx_state
*state
,
188 const char *data
, const char **ptr
, struct d3dx_object
*objects
);
189 static void free_parameter(struct d3dx_parameter
*param
, BOOL element
, BOOL child
);
193 enum STATE_CLASS
class;
200 {SC_RENDERSTATE
, D3DRS_ZENABLE
, "D3DRS_ZENABLE"}, /* 0x0 */
201 {SC_RENDERSTATE
, D3DRS_FILLMODE
, "D3DRS_FILLMODE"},
202 {SC_RENDERSTATE
, D3DRS_SHADEMODE
, "D3DRS_SHADEMODE"},
203 {SC_RENDERSTATE
, D3DRS_ZWRITEENABLE
, "D3DRS_ZWRITEENABLE"},
204 {SC_RENDERSTATE
, D3DRS_ALPHATESTENABLE
, "D3DRS_ALPHATESTENABLE"},
205 {SC_RENDERSTATE
, D3DRS_LASTPIXEL
, "D3DRS_LASTPIXEL"},
206 {SC_RENDERSTATE
, D3DRS_SRCBLEND
, "D3DRS_SRCBLEND"},
207 {SC_RENDERSTATE
, D3DRS_DESTBLEND
, "D3DRS_DESTBLEND"},
208 {SC_RENDERSTATE
, D3DRS_CULLMODE
, "D3DRS_CULLMODE"},
209 {SC_RENDERSTATE
, D3DRS_ZFUNC
, "D3DRS_ZFUNC"},
210 {SC_RENDERSTATE
, D3DRS_ALPHAREF
, "D3DRS_ALPHAREF"},
211 {SC_RENDERSTATE
, D3DRS_ALPHAFUNC
, "D3DRS_ALPHAFUNC"},
212 {SC_RENDERSTATE
, D3DRS_DITHERENABLE
, "D3DRS_DITHERENABLE"},
213 {SC_RENDERSTATE
, D3DRS_ALPHABLENDENABLE
, "D3DRS_ALPHABLENDENABLE"},
214 {SC_RENDERSTATE
, D3DRS_FOGENABLE
, "D3DRS_FOGENABLE"},
215 {SC_RENDERSTATE
, D3DRS_SPECULARENABLE
, "D3DRS_SPECULARENABLE"},
216 {SC_RENDERSTATE
, D3DRS_FOGCOLOR
, "D3DRS_FOGCOLOR"}, /* 0x10 */
217 {SC_RENDERSTATE
, D3DRS_FOGTABLEMODE
, "D3DRS_FOGTABLEMODE"},
218 {SC_RENDERSTATE
, D3DRS_FOGSTART
, "D3DRS_FOGSTART"},
219 {SC_RENDERSTATE
, D3DRS_FOGEND
, "D3DRS_FOGEND"},
220 {SC_RENDERSTATE
, D3DRS_FOGDENSITY
, "D3DRS_FOGDENSITY"},
221 {SC_RENDERSTATE
, D3DRS_RANGEFOGENABLE
, "D3DRS_RANGEFOGENABLE"},
222 {SC_RENDERSTATE
, D3DRS_STENCILENABLE
, "D3DRS_STENCILENABLE"},
223 {SC_RENDERSTATE
, D3DRS_STENCILFAIL
, "D3DRS_STENCILFAIL"},
224 {SC_RENDERSTATE
, D3DRS_STENCILZFAIL
, "D3DRS_STENCILZFAIL"},
225 {SC_RENDERSTATE
, D3DRS_STENCILPASS
, "D3DRS_STENCILPASS"},
226 {SC_RENDERSTATE
, D3DRS_STENCILFUNC
, "D3DRS_STENCILFUNC"},
227 {SC_RENDERSTATE
, D3DRS_STENCILREF
, "D3DRS_STENCILREF"},
228 {SC_RENDERSTATE
, D3DRS_STENCILMASK
, "D3DRS_STENCILMASK"},
229 {SC_RENDERSTATE
, D3DRS_STENCILWRITEMASK
, "D3DRS_STENCILWRITEMASK"},
230 {SC_RENDERSTATE
, D3DRS_TEXTUREFACTOR
, "D3DRS_TEXTUREFACTOR"},
231 {SC_RENDERSTATE
, D3DRS_WRAP0
, "D3DRS_WRAP0"},
232 {SC_RENDERSTATE
, D3DRS_WRAP1
, "D3DRS_WRAP1"}, /* 0x20 */
233 {SC_RENDERSTATE
, D3DRS_WRAP2
, "D3DRS_WRAP2"},
234 {SC_RENDERSTATE
, D3DRS_WRAP3
, "D3DRS_WRAP3"},
235 {SC_RENDERSTATE
, D3DRS_WRAP4
, "D3DRS_WRAP4"},
236 {SC_RENDERSTATE
, D3DRS_WRAP5
, "D3DRS_WRAP5"},
237 {SC_RENDERSTATE
, D3DRS_WRAP6
, "D3DRS_WRAP6"},
238 {SC_RENDERSTATE
, D3DRS_WRAP7
, "D3DRS_WRAP7"},
239 {SC_RENDERSTATE
, D3DRS_WRAP8
, "D3DRS_WRAP8"},
240 {SC_RENDERSTATE
, D3DRS_WRAP9
, "D3DRS_WRAP9"},
241 {SC_RENDERSTATE
, D3DRS_WRAP10
, "D3DRS_WRAP10"},
242 {SC_RENDERSTATE
, D3DRS_WRAP11
, "D3DRS_WRAP11"},
243 {SC_RENDERSTATE
, D3DRS_WRAP12
, "D3DRS_WRAP12"},
244 {SC_RENDERSTATE
, D3DRS_WRAP13
, "D3DRS_WRAP13"},
245 {SC_RENDERSTATE
, D3DRS_WRAP14
, "D3DRS_WRAP14"},
246 {SC_RENDERSTATE
, D3DRS_WRAP15
, "D3DRS_WRAP15"},
247 {SC_RENDERSTATE
, D3DRS_CLIPPING
, "D3DRS_CLIPPING"},
248 {SC_RENDERSTATE
, D3DRS_LIGHTING
, "D3DRS_LIGHTING"}, /* 0x30 */
249 {SC_RENDERSTATE
, D3DRS_AMBIENT
, "D3DRS_AMBIENT"},
250 {SC_RENDERSTATE
, D3DRS_FOGVERTEXMODE
, "D3DRS_FOGVERTEXMODE"},
251 {SC_RENDERSTATE
, D3DRS_COLORVERTEX
, "D3DRS_COLORVERTEX"},
252 {SC_RENDERSTATE
, D3DRS_LOCALVIEWER
, "D3DRS_LOCALVIEWER"},
253 {SC_RENDERSTATE
, D3DRS_NORMALIZENORMALS
, "D3DRS_NORMALIZENORMALS"},
254 {SC_RENDERSTATE
, D3DRS_DIFFUSEMATERIALSOURCE
, "D3DRS_DIFFUSEMATERIALSOURCE"},
255 {SC_RENDERSTATE
, D3DRS_SPECULARMATERIALSOURCE
, "D3DRS_SPECULARMATERIALSOURCE"},
256 {SC_RENDERSTATE
, D3DRS_AMBIENTMATERIALSOURCE
, "D3DRS_AMBIENTMATERIALSOURCE"},
257 {SC_RENDERSTATE
, D3DRS_EMISSIVEMATERIALSOURCE
, "D3DRS_EMISSIVEMATERIALSOURCE"},
258 {SC_RENDERSTATE
, D3DRS_VERTEXBLEND
, "D3DRS_VERTEXBLEND"},
259 {SC_RENDERSTATE
, D3DRS_CLIPPLANEENABLE
, "D3DRS_CLIPPLANEENABLE"},
260 {SC_RENDERSTATE
, D3DRS_POINTSIZE
, "D3DRS_POINTSIZE"},
261 {SC_RENDERSTATE
, D3DRS_POINTSIZE_MIN
, "D3DRS_POINTSIZE_MIN"},
262 {SC_RENDERSTATE
, D3DRS_POINTSIZE_MAX
, "D3DRS_POINTSIZE_MAX"},
263 {SC_RENDERSTATE
, D3DRS_POINTSPRITEENABLE
, "D3DRS_POINTSPRITEENABLE"},
264 {SC_RENDERSTATE
, D3DRS_POINTSCALEENABLE
, "D3DRS_POINTSCALEENABLE"}, /* 0x40 */
265 {SC_RENDERSTATE
, D3DRS_POINTSCALE_A
, "D3DRS_POINTSCALE_A"},
266 {SC_RENDERSTATE
, D3DRS_POINTSCALE_B
, "D3DRS_POINTSCALE_B"},
267 {SC_RENDERSTATE
, D3DRS_POINTSCALE_C
, "D3DRS_POINTSCALE_C"},
268 {SC_RENDERSTATE
, D3DRS_MULTISAMPLEANTIALIAS
, "D3DRS_MULTISAMPLEANTIALIAS"},
269 {SC_RENDERSTATE
, D3DRS_MULTISAMPLEMASK
, "D3DRS_MULTISAMPLEMASK"},
270 {SC_RENDERSTATE
, D3DRS_PATCHEDGESTYLE
, "D3DRS_PATCHEDGESTYLE"},
271 {SC_RENDERSTATE
, D3DRS_DEBUGMONITORTOKEN
, "D3DRS_DEBUGMONITORTOKEN"},
272 {SC_RENDERSTATE
, D3DRS_INDEXEDVERTEXBLENDENABLE
, "D3DRS_INDEXEDVERTEXBLENDENABLE"},
273 {SC_RENDERSTATE
, D3DRS_COLORWRITEENABLE
, "D3DRS_COLORWRITEENABLE"},
274 {SC_RENDERSTATE
, D3DRS_TWEENFACTOR
, "D3DRS_TWEENFACTOR"},
275 {SC_RENDERSTATE
, D3DRS_BLENDOP
, "D3DRS_BLENDOP"},
276 {SC_RENDERSTATE
, D3DRS_POSITIONDEGREE
, "D3DRS_POSITIONDEGREE"},
277 {SC_RENDERSTATE
, D3DRS_NORMALDEGREE
, "D3DRS_NORMALDEGREE"},
278 {SC_RENDERSTATE
, D3DRS_SCISSORTESTENABLE
, "D3DRS_SCISSORTESTENABLE"},
279 {SC_RENDERSTATE
, D3DRS_SLOPESCALEDEPTHBIAS
, "D3DRS_SLOPESCALEDEPTHBIAS"},
280 {SC_RENDERSTATE
, D3DRS_ANTIALIASEDLINEENABLE
, "D3DRS_ANTIALIASEDLINEENABLE"}, /* 0x50 */
281 {SC_RENDERSTATE
, D3DRS_MINTESSELLATIONLEVEL
, "D3DRS_MINTESSELLATIONLEVEL"},
282 {SC_RENDERSTATE
, D3DRS_MAXTESSELLATIONLEVEL
, "D3DRS_MAXTESSELLATIONLEVEL"},
283 {SC_RENDERSTATE
, D3DRS_ADAPTIVETESS_X
, "D3DRS_ADAPTIVETESS_X"},
284 {SC_RENDERSTATE
, D3DRS_ADAPTIVETESS_Y
, "D3DRS_ADAPTIVETESS_Y"},
285 {SC_RENDERSTATE
, D3DRS_ADAPTIVETESS_Z
, "D3DRS_ADAPTIVETESS_Z"},
286 {SC_RENDERSTATE
, D3DRS_ADAPTIVETESS_W
, "D3DRS_ADAPTIVETESS_W"},
287 {SC_RENDERSTATE
, D3DRS_ENABLEADAPTIVETESSELLATION
, "D3DRS_ENABLEADAPTIVETESSELLATION"},
288 {SC_RENDERSTATE
, D3DRS_TWOSIDEDSTENCILMODE
, "D3DRS_TWOSIDEDSTENCILMODE"},
289 {SC_RENDERSTATE
, D3DRS_CCW_STENCILFAIL
, "D3DRS_CCW_STENCILFAIL"},
290 {SC_RENDERSTATE
, D3DRS_CCW_STENCILZFAIL
, "D3DRS_CCW_STENCILZFAIL"},
291 {SC_RENDERSTATE
, D3DRS_CCW_STENCILPASS
, "D3DRS_CCW_STENCILPASS"},
292 {SC_RENDERSTATE
, D3DRS_CCW_STENCILFUNC
, "D3DRS_CCW_STENCILFUNC"},
293 {SC_RENDERSTATE
, D3DRS_COLORWRITEENABLE1
, "D3DRS_COLORWRITEENABLE1"},
294 {SC_RENDERSTATE
, D3DRS_COLORWRITEENABLE2
, "D3DRS_COLORWRITEENABLE2"},
295 {SC_RENDERSTATE
, D3DRS_COLORWRITEENABLE3
, "D3DRS_COLORWRITEENABLE3"},
296 {SC_RENDERSTATE
, D3DRS_BLENDFACTOR
, "D3DRS_BLENDFACTOR"}, /* 0x60 */
297 {SC_RENDERSTATE
, D3DRS_SRGBWRITEENABLE
, "D3DRS_SRGBWRITEENABLE"},
298 {SC_RENDERSTATE
, D3DRS_DEPTHBIAS
, "D3DRS_DEPTHBIAS"},
299 {SC_RENDERSTATE
, D3DRS_SEPARATEALPHABLENDENABLE
, "D3DRS_SEPARATEALPHABLENDENABLE"},
300 {SC_RENDERSTATE
, D3DRS_SRCBLENDALPHA
, "D3DRS_SRCBLENDALPHA"},
301 {SC_RENDERSTATE
, D3DRS_DESTBLENDALPHA
, "D3DRS_DESTBLENDALPHA"},
302 {SC_RENDERSTATE
, D3DRS_BLENDOPALPHA
, "D3DRS_BLENDOPALPHA"},
304 {SC_TEXTURESTAGE
, D3DTSS_COLOROP
, "D3DTSS_COLOROP"},
305 {SC_TEXTURESTAGE
, D3DTSS_COLORARG0
, "D3DTSS_COLORARG0"},
306 {SC_TEXTURESTAGE
, D3DTSS_COLORARG1
, "D3DTSS_COLORARG1"},
307 {SC_TEXTURESTAGE
, D3DTSS_COLORARG2
, "D3DTSS_COLORARG2"},
308 {SC_TEXTURESTAGE
, D3DTSS_ALPHAOP
, "D3DTSS_ALPHAOP"},
309 {SC_TEXTURESTAGE
, D3DTSS_ALPHAARG0
, "D3DTSS_ALPHAARG0"},
310 {SC_TEXTURESTAGE
, D3DTSS_ALPHAARG1
, "D3DTSS_ALPHAARG1"},
311 {SC_TEXTURESTAGE
, D3DTSS_ALPHAARG2
, "D3DTSS_ALPHAARG2"},
312 {SC_TEXTURESTAGE
, D3DTSS_RESULTARG
, "D3DTSS_RESULTARG"},
313 {SC_TEXTURESTAGE
, D3DTSS_BUMPENVMAT00
, "D3DTSS_BUMPENVMAT00"}, /* 0x70 */
314 {SC_TEXTURESTAGE
, D3DTSS_BUMPENVMAT01
, "D3DTSS_BUMPENVMAT01"},
315 {SC_TEXTURESTAGE
, D3DTSS_BUMPENVMAT10
, "D3DTSS_BUMPENVMAT10"},
316 {SC_TEXTURESTAGE
, D3DTSS_BUMPENVMAT11
, "D3DTSS_BUMPENVMAT11"},
317 {SC_TEXTURESTAGE
, D3DTSS_TEXCOORDINDEX
, "D3DTSS_TEXCOORDINDEX"},
318 {SC_TEXTURESTAGE
, D3DTSS_BUMPENVLSCALE
, "D3DTSS_BUMPENVLSCALE"},
319 {SC_TEXTURESTAGE
, D3DTSS_BUMPENVLOFFSET
, "D3DTSS_BUMPENVLOFFSET"},
320 {SC_TEXTURESTAGE
, D3DTSS_TEXTURETRANSFORMFLAGS
, "D3DTSS_TEXTURETRANSFORMFLAGS"},
321 {SC_TEXTURESTAGE
, D3DTSS_CONSTANT
, "D3DTSS_CONSTANT"},
323 {SC_NPATCHMODE
, 0, "NPatchMode"},
327 {SC_TRANSFORM
, D3DTS_PROJECTION
, "D3DTS_PROJECTION"},
328 {SC_TRANSFORM
, D3DTS_VIEW
, "D3DTS_VIEW"},
329 {SC_TRANSFORM
, D3DTS_WORLD
, "D3DTS_WORLD"},
330 {SC_TRANSFORM
, D3DTS_TEXTURE0
, "D3DTS_TEXTURE0"},
332 {SC_MATERIAL
, MT_DIFFUSE
, "MaterialDiffuse"},
333 {SC_MATERIAL
, MT_AMBIENT
, "MaterialAmbient"}, /* 0x80 */
334 {SC_MATERIAL
, MT_SPECULAR
, "MaterialSpecular"},
335 {SC_MATERIAL
, MT_EMISSIVE
, "MaterialEmissive"},
336 {SC_MATERIAL
, MT_POWER
, "MaterialPower"},
338 {SC_LIGHT
, LT_TYPE
, "LightType"},
339 {SC_LIGHT
, LT_DIFFUSE
, "LightDiffuse"},
340 {SC_LIGHT
, LT_SPECULAR
, "LightSpecular"},
341 {SC_LIGHT
, LT_AMBIENT
, "LightAmbient"},
342 {SC_LIGHT
, LT_POSITION
, "LightPosition"},
343 {SC_LIGHT
, LT_DIRECTION
, "LightDirection"},
344 {SC_LIGHT
, LT_RANGE
, "LightRange"},
345 {SC_LIGHT
, LT_FALLOFF
, "LightFallOff"},
346 {SC_LIGHT
, LT_ATTENUATION0
, "LightAttenuation0"},
347 {SC_LIGHT
, LT_ATTENUATION1
, "LightAttenuation1"},
348 {SC_LIGHT
, LT_ATTENUATION2
, "LightAttenuation2"},
349 {SC_LIGHT
, LT_THETA
, "LightTheta"},
350 {SC_LIGHT
, LT_PHI
, "LightPhi"}, /* 0x90 */
352 {SC_LIGHTENABLE
, 0, "LightEnable"},
354 {SC_VERTEXSHADER
, 0, "Vertexshader"},
356 {SC_PIXELSHADER
, 0, "Pixelshader"},
357 /* Shader constants */
358 {SC_SHADERCONST
, SCT_VSFLOAT
, "VertexShaderConstantF"},
359 {SC_SHADERCONST
, SCT_VSBOOL
, "VertexShaderConstantB"},
360 {SC_SHADERCONST
, SCT_VSINT
, "VertexShaderConstantI"},
361 {SC_SHADERCONST
, SCT_VSFLOAT
, "VertexShaderConstant"},
362 {SC_SHADERCONST
, SCT_VSFLOAT
, "VertexShaderConstant1"},
363 {SC_SHADERCONST
, SCT_VSFLOAT
, "VertexShaderConstant2"},
364 {SC_SHADERCONST
, SCT_VSFLOAT
, "VertexShaderConstant3"},
365 {SC_SHADERCONST
, SCT_VSFLOAT
, "VertexShaderConstant4"},
366 {SC_SHADERCONST
, SCT_PSFLOAT
, "PixelShaderConstantF"},
367 {SC_SHADERCONST
, SCT_PSBOOL
, "PixelShaderConstantB"},
368 {SC_SHADERCONST
, SCT_PSINT
, "PixelShaderConstantI"},
369 {SC_SHADERCONST
, SCT_PSFLOAT
, "PixelShaderConstant"},
370 {SC_SHADERCONST
, SCT_PSFLOAT
, "PixelShaderConstant1"}, /* 0xa0 */
371 {SC_SHADERCONST
, SCT_PSFLOAT
, "PixelShaderConstant2"},
372 {SC_SHADERCONST
, SCT_PSFLOAT
, "PixelShaderConstant3"},
373 {SC_SHADERCONST
, SCT_PSFLOAT
, "PixelShaderConstant4"},
375 {SC_TEXTURE
, 0, "Texture"},
377 {SC_SAMPLERSTATE
, D3DSAMP_ADDRESSU
, "AddressU"},
378 {SC_SAMPLERSTATE
, D3DSAMP_ADDRESSV
, "AddressV"},
379 {SC_SAMPLERSTATE
, D3DSAMP_ADDRESSW
, "AddressW"},
380 {SC_SAMPLERSTATE
, D3DSAMP_BORDERCOLOR
, "BorderColor"},
381 {SC_SAMPLERSTATE
, D3DSAMP_MAGFILTER
, "MagFilter"},
382 {SC_SAMPLERSTATE
, D3DSAMP_MINFILTER
, "MinFilter"},
383 {SC_SAMPLERSTATE
, D3DSAMP_MIPFILTER
, "MipFilter"},
384 {SC_SAMPLERSTATE
, D3DSAMP_MIPMAPLODBIAS
, "MipMapLodBias"},
385 {SC_SAMPLERSTATE
, D3DSAMP_MAXMIPLEVEL
, "MaxMipLevel"},
386 {SC_SAMPLERSTATE
, D3DSAMP_MAXANISOTROPY
, "MaxAnisotropy"},
387 {SC_SAMPLERSTATE
, D3DSAMP_SRGBTEXTURE
, "SRGBTexture"},
388 {SC_SAMPLERSTATE
, D3DSAMP_ELEMENTINDEX
, "ElementIndex"}, /* 0xb0 */
389 {SC_SAMPLERSTATE
, D3DSAMP_DMAPOFFSET
, "DMAPOffset"},
391 {SC_SETSAMPLER
, 0, "Sampler"},
394 static inline void read_dword(const char **ptr
, DWORD
*d
)
396 memcpy(d
, *ptr
, sizeof(*d
));
400 static void skip_dword_unknown(const char **ptr
, unsigned int count
)
405 FIXME("Skipping %u unknown DWORDs:\n", count
);
406 for (i
= 0; i
< count
; ++i
)
409 FIXME("\t0x%08x\n", d
);
413 static inline D3DXHANDLE
get_parameter_handle(struct d3dx_parameter
*parameter
)
415 return parameter
? parameter
->handle
: NULL
;
418 static inline D3DXHANDLE
get_technique_handle(struct d3dx_technique
*technique
)
420 return (D3DXHANDLE
) technique
;
423 static inline D3DXHANDLE
get_pass_handle(struct d3dx_pass
*pass
)
425 return (D3DXHANDLE
) pass
;
428 static struct d3dx_technique
*get_technique_by_name(struct d3dx9_base_effect
*base
, const char *name
)
432 if (!name
) return NULL
;
434 for (i
= 0; i
< base
->technique_count
; ++i
)
436 if (!strcmp(base
->techniques
[i
].name
, name
))
437 return &base
->techniques
[i
];
443 static struct d3dx_technique
*get_valid_technique(struct d3dx9_base_effect
*base
, D3DXHANDLE technique
)
447 for (i
= 0; i
< base
->technique_count
; ++i
)
449 if (get_technique_handle(&base
->techniques
[i
]) == technique
)
450 return &base
->techniques
[i
];
453 return get_technique_by_name(base
, technique
);
456 static struct d3dx_pass
*get_valid_pass(struct d3dx9_base_effect
*base
, D3DXHANDLE pass
)
460 for (i
= 0; i
< base
->technique_count
; ++i
)
462 struct d3dx_technique
*technique
= &base
->techniques
[i
];
464 for (k
= 0; k
< technique
->pass_count
; ++k
)
466 if (get_pass_handle(&technique
->passes
[k
]) == pass
)
467 return &technique
->passes
[k
];
474 static struct d3dx_parameter
*get_valid_parameter(struct d3dx9_base_effect
*base
, D3DXHANDLE parameter
)
476 struct d3dx_parameter
**handle_param
= (struct d3dx_parameter
**)parameter
;
478 if (handle_param
>= base
->param_table
.table
&& handle_param
< base
->param_table
.table
+ base
->param_table
.count
)
479 return *handle_param
;
481 return get_parameter_by_name(base
, NULL
, parameter
);
484 static void free_state(struct d3dx_state
*state
)
486 free_parameter(&state
->parameter
, FALSE
, FALSE
);
489 static void free_object(struct d3dx_object
*object
)
491 HeapFree(GetProcessHeap(), 0, object
->data
);
494 static void free_sampler(struct d3dx_sampler
*sampler
)
498 for (i
= 0; i
< sampler
->state_count
; ++i
)
500 free_state(&sampler
->states
[i
]);
502 HeapFree(GetProcessHeap(), 0, sampler
->states
);
505 static void free_parameter(struct d3dx_parameter
*param
, BOOL element
, BOOL child
)
509 TRACE("Free parameter %p, name %s, type %s, child %s\n", param
, param
->name
,
510 debug_d3dxparameter_type(param
->type
), child
? "yes" : "no");
512 if (param
->param_eval
)
514 d3dx_free_param_eval(param
->param_eval
);
515 param
->param_eval
= NULL
;
518 if (param
->annotations
)
520 for (i
= 0; i
< param
->annotation_count
; ++i
)
521 free_parameter(¶m
->annotations
[i
], FALSE
, FALSE
);
522 HeapFree(GetProcessHeap(), 0, param
->annotations
);
523 param
->annotations
= NULL
;
528 unsigned int count
= param
->element_count
? param
->element_count
: param
->member_count
;
530 for (i
= 0; i
< count
; ++i
)
531 free_parameter(¶m
->members
[i
], param
->element_count
!= 0, TRUE
);
532 HeapFree(GetProcessHeap(), 0, param
->members
);
533 param
->members
= NULL
;
536 if (param
->class == D3DXPC_OBJECT
&& !param
->element_count
)
541 HeapFree(GetProcessHeap(), 0, *(char **)param
->data
);
545 case D3DXPT_TEXTURE1D
:
546 case D3DXPT_TEXTURE2D
:
547 case D3DXPT_TEXTURE3D
:
548 case D3DXPT_TEXTURECUBE
:
549 case D3DXPT_PIXELSHADER
:
550 case D3DXPT_VERTEXSHADER
:
551 if (*(IUnknown
**)param
->data
) IUnknown_Release(*(IUnknown
**)param
->data
);
555 case D3DXPT_SAMPLER1D
:
556 case D3DXPT_SAMPLER2D
:
557 case D3DXPT_SAMPLER3D
:
558 case D3DXPT_SAMPLERCUBE
:
559 free_sampler((struct d3dx_sampler
*)param
->data
);
563 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
570 HeapFree(GetProcessHeap(), 0, param
->data
);
573 /* only the parent has to release name and semantic */
576 HeapFree(GetProcessHeap(), 0, param
->name
);
577 HeapFree(GetProcessHeap(), 0, param
->semantic
);
581 static void free_pass(struct d3dx_pass
*pass
)
585 TRACE("Free pass %p\n", pass
);
590 if (pass
->annotations
)
592 for (i
= 0; i
< pass
->annotation_count
; ++i
)
593 free_parameter(&pass
->annotations
[i
], FALSE
, FALSE
);
594 HeapFree(GetProcessHeap(), 0, pass
->annotations
);
595 pass
->annotations
= NULL
;
600 for (i
= 0; i
< pass
->state_count
; ++i
)
601 free_state(&pass
->states
[i
]);
602 HeapFree(GetProcessHeap(), 0, pass
->states
);
606 HeapFree(GetProcessHeap(), 0, pass
->name
);
610 static void free_technique(struct d3dx_technique
*technique
)
614 TRACE("Free technique %p\n", technique
);
619 if (technique
->saved_state
)
621 IDirect3DStateBlock9_Release(technique
->saved_state
);
622 technique
->saved_state
= NULL
;
625 if (technique
->annotations
)
627 for (i
= 0; i
< technique
->annotation_count
; ++i
)
628 free_parameter(&technique
->annotations
[i
], FALSE
, FALSE
);
629 HeapFree(GetProcessHeap(), 0, technique
->annotations
);
630 technique
->annotations
= NULL
;
633 if (technique
->passes
)
635 for (i
= 0; i
< technique
->pass_count
; ++i
)
636 free_pass(&technique
->passes
[i
]);
637 HeapFree(GetProcessHeap(), 0, technique
->passes
);
638 technique
->passes
= NULL
;
641 HeapFree(GetProcessHeap(), 0, technique
->name
);
642 technique
->name
= NULL
;
645 static void d3dx9_base_effect_cleanup(struct d3dx9_base_effect
*base
)
649 TRACE("base %p.\n", base
);
651 HeapFree(GetProcessHeap(), 0, base
->param_table
.table
);
653 if (base
->parameters
)
655 for (i
= 0; i
< base
->parameter_count
; ++i
)
656 free_parameter(&base
->parameters
[i
], FALSE
, FALSE
);
657 HeapFree(GetProcessHeap(), 0, base
->parameters
);
658 base
->parameters
= NULL
;
661 if (base
->techniques
)
663 for (i
= 0; i
< base
->technique_count
; ++i
)
664 free_technique(&base
->techniques
[i
]);
665 HeapFree(GetProcessHeap(), 0, base
->techniques
);
666 base
->techniques
= NULL
;
671 for (i
= 0; i
< base
->object_count
; ++i
)
673 free_object(&base
->objects
[i
]);
675 HeapFree(GetProcessHeap(), 0, base
->objects
);
676 base
->objects
= NULL
;
680 static void free_effect(struct ID3DXEffectImpl
*effect
)
682 TRACE("Free effect %p\n", effect
);
684 d3dx9_base_effect_cleanup(&effect
->base_effect
);
688 effect
->pool
->lpVtbl
->Release(effect
->pool
);
693 IUnknown_Release(effect
->manager
);
696 IDirect3DDevice9_Release(effect
->device
);
699 static void free_effect_compiler(struct ID3DXEffectCompilerImpl
*compiler
)
701 TRACE("Free effect compiler %p\n", compiler
);
703 d3dx9_base_effect_cleanup(&compiler
->base_effect
);
706 static void get_vector(struct d3dx_parameter
*param
, D3DXVECTOR4
*vector
)
710 for (i
= 0; i
< 4; ++i
)
712 if (i
< param
->columns
)
713 set_number((FLOAT
*)vector
+ i
, D3DXPT_FLOAT
, (DWORD
*)param
->data
+ i
, param
->type
);
715 ((FLOAT
*)vector
)[i
] = 0.0f
;
719 static void set_vector(struct d3dx_parameter
*param
, const D3DXVECTOR4
*vector
)
723 for (i
= 0; i
< param
->columns
; ++i
)
725 set_number((FLOAT
*)param
->data
+ i
, param
->type
, (FLOAT
*)vector
+ i
, D3DXPT_FLOAT
);
729 static void get_matrix(struct d3dx_parameter
*param
, D3DXMATRIX
*matrix
, BOOL transpose
)
733 for (i
= 0; i
< 4; ++i
)
735 for (k
= 0; k
< 4; ++k
)
737 FLOAT
*tmp
= transpose
? (FLOAT
*)&matrix
->u
.m
[k
][i
] : (FLOAT
*)&matrix
->u
.m
[i
][k
];
739 if ((i
< param
->rows
) && (k
< param
->columns
))
740 set_number(tmp
, D3DXPT_FLOAT
, (DWORD
*)param
->data
+ i
* param
->columns
+ k
, param
->type
);
747 static void set_matrix(struct d3dx_parameter
*param
, const D3DXMATRIX
*matrix
)
751 if (param
->type
== D3DXPT_FLOAT
)
753 if (param
->columns
== 4)
754 memcpy(param
->data
, matrix
->u
.m
, param
->rows
* 4 * sizeof(float));
756 for (i
= 0; i
< param
->rows
; ++i
)
757 memcpy((float *)param
->data
+ i
* param
->columns
, matrix
->u
.m
+ i
, param
->columns
* sizeof(float));
761 for (i
= 0; i
< param
->rows
; ++i
)
763 for (k
= 0; k
< param
->columns
; ++k
)
765 set_number((FLOAT
*)param
->data
+ i
* param
->columns
+ k
, param
->type
,
766 &matrix
->u
.m
[i
][k
], D3DXPT_FLOAT
);
771 static void set_matrix_transpose(struct d3dx_parameter
*param
, const D3DXMATRIX
*matrix
)
775 for (i
= 0; i
< param
->rows
; ++i
)
777 for (k
= 0; k
< param
->columns
; ++k
)
779 set_number((FLOAT
*)param
->data
+ i
* param
->columns
+ k
, param
->type
,
780 &matrix
->u
.m
[k
][i
], D3DXPT_FLOAT
);
785 static struct d3dx_parameter
*get_parameter_element_by_name(struct d3dx_parameter
*parameter
, const char *name
)
788 struct d3dx_parameter
*temp_parameter
;
791 TRACE("parameter %p, name %s\n", parameter
, debugstr_a(name
));
793 if (!name
|| !*name
) return NULL
;
795 element
= atoi(name
);
796 part
= strchr(name
, ']') + 1;
798 /* check for empty [] && element range */
799 if ((part
- name
) > 1 && parameter
->element_count
> element
)
801 temp_parameter
= ¶meter
->members
[element
];
806 return get_parameter_by_name(NULL
, temp_parameter
, part
);
809 return get_annotation_by_name(temp_parameter
->annotation_count
, temp_parameter
->annotations
, part
);
812 TRACE("Returning parameter %p\n", temp_parameter
);
813 return temp_parameter
;
816 FIXME("Unhandled case \"%c\"\n", *--part
);
821 TRACE("Parameter not found\n");
825 static struct d3dx_parameter
*get_annotation_by_name(UINT count
, struct d3dx_parameter
*annotations
,
829 struct d3dx_parameter
*temp_parameter
;
832 TRACE("count %u, annotations %p, name %s\n", count
, annotations
, debugstr_a(name
));
834 if (!name
|| !*name
) return NULL
;
836 length
= strcspn( name
, "[.@" );
837 part
= name
+ length
;
839 for (i
= 0; i
< count
; ++i
)
841 temp_parameter
= &annotations
[i
];
843 if (!strcmp(temp_parameter
->name
, name
))
845 TRACE("Returning annotation %p\n", temp_parameter
);
846 return temp_parameter
;
848 else if (strlen(temp_parameter
->name
) == length
&& !strncmp(temp_parameter
->name
, name
, length
))
853 return get_parameter_by_name(NULL
, temp_parameter
, part
);
856 return get_parameter_element_by_name(temp_parameter
, part
);
859 FIXME("Unhandled case \"%c\"\n", *--part
);
865 TRACE("Annotation not found\n");
869 struct d3dx_parameter
*get_parameter_by_name(struct d3dx9_base_effect
*base
,
870 struct d3dx_parameter
*parameter
, const char *name
)
872 UINT i
, count
, length
;
873 struct d3dx_parameter
*temp_parameter
;
874 struct d3dx_parameter
*parameters
;
877 TRACE("base %p, parameter %p, name %s\n", base
, parameter
, debugstr_a(name
));
879 if (!name
|| !*name
) return NULL
;
883 count
= base
->parameter_count
;
884 parameters
= base
->parameters
;
888 count
= parameter
->member_count
;
889 parameters
= parameter
->members
;
892 length
= strcspn( name
, "[.@" );
893 part
= name
+ length
;
895 for (i
= 0; i
< count
; i
++)
897 temp_parameter
= ¶meters
[i
];
899 if (!strcmp(temp_parameter
->name
, name
))
901 TRACE("Returning parameter %p\n", temp_parameter
);
902 return temp_parameter
;
904 else if (strlen(temp_parameter
->name
) == length
&& !strncmp(temp_parameter
->name
, name
, length
))
909 return get_parameter_by_name(NULL
, temp_parameter
, part
);
912 return get_annotation_by_name(temp_parameter
->annotation_count
, temp_parameter
->annotations
, part
);
915 return get_parameter_element_by_name(temp_parameter
, part
);
918 FIXME("Unhandled case \"%c\"\n", *--part
);
924 TRACE("Parameter not found\n");
928 static inline DWORD
d3dx9_effect_version(DWORD major
, DWORD minor
)
930 return (0xfeff0000 | ((major
) << 8) | (minor
));
933 static HRESULT
d3dx9_base_effect_get_desc(struct d3dx9_base_effect
*base
, D3DXEFFECT_DESC
*desc
)
937 WARN("Invalid argument specified.\n");
938 return D3DERR_INVALIDCALL
;
941 FIXME("partial stub!\n");
943 /* TODO: add creator and function count. */
944 desc
->Creator
= NULL
;
946 desc
->Parameters
= base
->parameter_count
;
947 desc
->Techniques
= base
->technique_count
;
952 static HRESULT
d3dx9_base_effect_get_parameter_desc(struct d3dx9_base_effect
*base
,
953 D3DXHANDLE parameter
, D3DXPARAMETER_DESC
*desc
)
955 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
959 WARN("Invalid argument specified.\n");
960 return D3DERR_INVALIDCALL
;
963 desc
->Name
= param
->name
;
964 desc
->Semantic
= param
->semantic
;
965 desc
->Class
= param
->class;
966 desc
->Type
= param
->type
;
967 desc
->Rows
= param
->rows
;
968 desc
->Columns
= param
->columns
;
969 desc
->Elements
= param
->element_count
;
970 desc
->Annotations
= param
->annotation_count
;
971 desc
->StructMembers
= param
->member_count
;
972 desc
->Flags
= param
->flags
;
973 desc
->Bytes
= param
->bytes
;
978 static HRESULT
d3dx9_base_effect_get_technique_desc(struct d3dx9_base_effect
*base
,
979 D3DXHANDLE technique
, D3DXTECHNIQUE_DESC
*desc
)
981 struct d3dx_technique
*tech
= technique
? get_valid_technique(base
, technique
) : &base
->techniques
[0];
985 WARN("Invalid argument specified.\n");
986 return D3DERR_INVALIDCALL
;
989 desc
->Name
= tech
->name
;
990 desc
->Passes
= tech
->pass_count
;
991 desc
->Annotations
= tech
->annotation_count
;
996 static HRESULT
d3dx9_base_effect_get_pass_desc(struct d3dx9_base_effect
*base
,
997 D3DXHANDLE pass
, D3DXPASS_DESC
*desc
)
999 struct d3dx_pass
*p
= get_valid_pass(base
, pass
);
1003 WARN("Invalid argument specified.\n");
1004 return D3DERR_INVALIDCALL
;
1007 desc
->Name
= p
->name
;
1008 desc
->Annotations
= p
->annotation_count
;
1010 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
1011 desc
->pVertexShaderFunction
= NULL
;
1012 desc
->pPixelShaderFunction
= NULL
;
1017 static HRESULT
d3dx9_base_effect_get_function_desc(struct d3dx9_base_effect
*base
,
1018 D3DXHANDLE shader
, D3DXFUNCTION_DESC
*desc
)
1025 static D3DXHANDLE
d3dx9_base_effect_get_parameter(struct d3dx9_base_effect
*base
,
1026 D3DXHANDLE parameter
, UINT index
)
1028 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1032 if (index
< base
->parameter_count
)
1034 TRACE("Returning parameter %p.\n", &base
->parameters
[index
]);
1035 return get_parameter_handle(&base
->parameters
[index
]);
1040 if (param
&& !param
->element_count
&& index
< param
->member_count
)
1042 TRACE("Returning parameter %p.\n", ¶m
->members
[index
]);
1043 return get_parameter_handle(¶m
->members
[index
]);
1047 WARN("Parameter not found.\n");
1052 static D3DXHANDLE
d3dx9_base_effect_get_parameter_by_name(struct d3dx9_base_effect
*base
,
1053 D3DXHANDLE parameter
, const char *name
)
1055 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1060 handle
= get_parameter_handle(param
);
1061 TRACE("Returning parameter %p.\n", handle
);
1065 handle
= get_parameter_handle(get_parameter_by_name(base
, param
, name
));
1066 TRACE("Returning parameter %p.\n", handle
);
1071 static D3DXHANDLE
d3dx9_base_effect_get_parameter_by_semantic(struct d3dx9_base_effect
*base
,
1072 D3DXHANDLE parameter
, const char *semantic
)
1074 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1075 struct d3dx_parameter
*temp_param
;
1080 for (i
= 0; i
< base
->parameter_count
; ++i
)
1082 temp_param
= &base
->parameters
[i
];
1084 if (!temp_param
->semantic
)
1088 TRACE("Returning parameter %p\n", temp_param
);
1089 return get_parameter_handle(temp_param
);
1094 if (!strcasecmp(temp_param
->semantic
, semantic
))
1096 TRACE("Returning parameter %p\n", temp_param
);
1097 return get_parameter_handle(temp_param
);
1103 for (i
= 0; i
< param
->member_count
; ++i
)
1105 temp_param
= ¶m
->members
[i
];
1107 if (!temp_param
->semantic
)
1111 TRACE("Returning parameter %p\n", temp_param
);
1112 return get_parameter_handle(temp_param
);
1117 if (!strcasecmp(temp_param
->semantic
, semantic
))
1119 TRACE("Returning parameter %p\n", temp_param
);
1120 return get_parameter_handle(temp_param
);
1125 WARN("Parameter not found.\n");
1130 static D3DXHANDLE
d3dx9_base_effect_get_parameter_element(struct d3dx9_base_effect
*base
,
1131 D3DXHANDLE parameter
, UINT index
)
1133 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1137 if (index
< base
->parameter_count
)
1139 TRACE("Returning parameter %p.\n", &base
->parameters
[index
]);
1140 return get_parameter_handle(&base
->parameters
[index
]);
1145 if (index
< param
->element_count
)
1147 TRACE("Returning parameter %p.\n", ¶m
->members
[index
]);
1148 return get_parameter_handle(¶m
->members
[index
]);
1152 WARN("Parameter not found.\n");
1157 static D3DXHANDLE
d3dx9_base_effect_get_technique(struct d3dx9_base_effect
*base
, UINT index
)
1159 if (index
>= base
->technique_count
)
1161 WARN("Invalid argument specified.\n");
1165 TRACE("Returning technique %p.\n", &base
->techniques
[index
]);
1167 return get_technique_handle(&base
->techniques
[index
]);
1170 static D3DXHANDLE
d3dx9_base_effect_get_technique_by_name(struct d3dx9_base_effect
*base
, const char *name
)
1172 struct d3dx_technique
*tech
= get_technique_by_name(base
, name
);
1176 D3DXHANDLE t
= get_technique_handle(tech
);
1177 TRACE("Returning technique %p\n", t
);
1181 WARN("Technique not found.\n");
1186 static D3DXHANDLE
d3dx9_base_effect_get_pass(struct d3dx9_base_effect
*base
,
1187 D3DXHANDLE technique
, UINT index
)
1189 struct d3dx_technique
*tech
= get_valid_technique(base
, technique
);
1191 if (tech
&& index
< tech
->pass_count
)
1193 TRACE("Returning pass %p\n", &tech
->passes
[index
]);
1194 return get_pass_handle(&tech
->passes
[index
]);
1197 WARN("Pass not found.\n");
1202 static D3DXHANDLE
d3dx9_base_effect_get_pass_by_name(struct d3dx9_base_effect
*base
,
1203 D3DXHANDLE technique
, const char *name
)
1205 struct d3dx_technique
*tech
= get_valid_technique(base
, technique
);
1211 for (i
= 0; i
< tech
->pass_count
; ++i
)
1213 struct d3dx_pass
*pass
= &tech
->passes
[i
];
1215 if (!strcmp(pass
->name
, name
))
1217 TRACE("Returning pass %p\n", pass
);
1218 return get_pass_handle(pass
);
1223 WARN("Pass not found.\n");
1228 static D3DXHANDLE
d3dx9_base_effect_get_function(struct d3dx9_base_effect
*base
, UINT index
)
1235 static D3DXHANDLE
d3dx9_base_effect_get_function_by_name(struct d3dx9_base_effect
*base
, const char *name
)
1242 static UINT
get_annotation_from_object(struct d3dx9_base_effect
*base
,
1243 D3DXHANDLE object
, struct d3dx_parameter
**annotations
)
1245 struct d3dx_parameter
*param
= get_valid_parameter(base
, object
);
1246 struct d3dx_pass
*pass
= get_valid_pass(base
, object
);
1247 struct d3dx_technique
*technique
= get_valid_technique(base
, object
);
1251 *annotations
= pass
->annotations
;
1252 return pass
->annotation_count
;
1256 *annotations
= technique
->annotations
;
1257 return technique
->annotation_count
;
1261 *annotations
= param
->annotations
;
1262 return param
->annotation_count
;
1266 FIXME("Functions are not handled, yet!\n");
1271 static D3DXHANDLE
d3dx9_base_effect_get_annotation(struct d3dx9_base_effect
*base
,
1272 D3DXHANDLE object
, UINT index
)
1274 struct d3dx_parameter
*annotations
= NULL
;
1275 UINT annotation_count
= 0;
1277 annotation_count
= get_annotation_from_object(base
, object
, &annotations
);
1279 if (index
< annotation_count
)
1281 TRACE("Returning parameter %p\n", &annotations
[index
]);
1282 return get_parameter_handle(&annotations
[index
]);
1285 WARN("Annotation not found.\n");
1290 static D3DXHANDLE
d3dx9_base_effect_get_annotation_by_name(struct d3dx9_base_effect
*base
,
1291 D3DXHANDLE object
, const char *name
)
1293 struct d3dx_parameter
*annotation
= NULL
;
1294 struct d3dx_parameter
*annotations
= NULL
;
1295 UINT annotation_count
= 0;
1299 WARN("Invalid argument specified\n");
1303 annotation_count
= get_annotation_from_object(base
, object
, &annotations
);
1305 annotation
= get_annotation_by_name(annotation_count
, annotations
, name
);
1308 TRACE("Returning parameter %p\n", annotation
);
1309 return get_parameter_handle(annotation
);
1312 WARN("Annotation not found.\n");
1317 static HRESULT
d3dx9_base_effect_set_value(struct d3dx9_base_effect
*base
,
1318 D3DXHANDLE parameter
, const void *data
, UINT bytes
)
1320 struct d3dx_parameter
*param
= get_valid_parameter(base
, parameter
);
1324 WARN("Invalid parameter %p specified\n", parameter
);
1325 return D3DERR_INVALIDCALL
;
1328 /* samplers don't touch data */
1329 if (param
->class == D3DXPC_OBJECT
&& (param
->type
== D3DXPT_SAMPLER
1330 || param
->type
== D3DXPT_SAMPLER1D
|| param
->type
== D3DXPT_SAMPLER2D
1331 || param
->type
== D3DXPT_SAMPLER3D
|| param
->type
== D3DXPT_SAMPLERCUBE
))
1333 TRACE("Sampler: returning E_FAIL\n");
1337 if (data
&& param
->bytes
<= bytes
)
1339 switch (param
->type
)
1341 case D3DXPT_TEXTURE
:
1342 case D3DXPT_TEXTURE1D
:
1343 case D3DXPT_TEXTURE2D
:
1344 case D3DXPT_TEXTURE3D
:
1345 case D3DXPT_TEXTURECUBE
:
1349 for (i
= 0; i
< (param
->element_count
? param
->element_count
: 1); ++i
)
1351 IUnknown
*unk
= ((IUnknown
**)data
)[i
];
1353 IUnknown_AddRef(unk
);
1355 unk
= ((IUnknown
**)param
->data
)[i
];
1357 IUnknown_Release(unk
);
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 HRESULT
d3dx9_get_param_value_ptr(struct ID3DXEffectImpl
*effect
, struct d3dx_pass
*pass
,
2494 struct d3dx_state
*state
, void **param_value
, struct d3dx_parameter
**out_param
)
2496 struct d3dx_parameter
*param
;
2497 param
= state
->parameter
.referenced_param
? state
->parameter
.referenced_param
: &state
->parameter
;
2499 switch (state
->type
)
2503 *param_value
= param
->data
;
2506 case ST_ARRAY_SELECTOR
:
2507 FIXME("Array selector.\n");
2510 FIXME("FXLC not supported yet.\n");
2513 *param_value
= NULL
;
2518 static void d3dx9_set_light_parameter(enum LIGHT_TYPE op
, D3DLIGHT9
*light
, void *value
)
2522 unsigned int offset
;
2527 {FIELD_OFFSET(D3DLIGHT9
, Type
), "LC_TYPE"},
2528 {FIELD_OFFSET(D3DLIGHT9
, Diffuse
), "LT_DIFFUSE"},
2529 {FIELD_OFFSET(D3DLIGHT9
, Specular
), "LT_SPECULAR"},
2530 {FIELD_OFFSET(D3DLIGHT9
, Ambient
), "LT_AMBIENT"},
2531 {FIELD_OFFSET(D3DLIGHT9
, Position
), "LT_POSITION"},
2532 {FIELD_OFFSET(D3DLIGHT9
, Direction
), "LT_DIRECTION"},
2533 {FIELD_OFFSET(D3DLIGHT9
, Range
), "LT_RANGE"},
2534 {FIELD_OFFSET(D3DLIGHT9
, Falloff
), "LT_FALLOFF"},
2535 {FIELD_OFFSET(D3DLIGHT9
, Attenuation0
), "LT_ATTENUATION0"},
2536 {FIELD_OFFSET(D3DLIGHT9
, Attenuation1
), "LT_ATTENUATION1"},
2537 {FIELD_OFFSET(D3DLIGHT9
, Attenuation2
), "LT_ATTENUATION2"},
2538 {FIELD_OFFSET(D3DLIGHT9
, Theta
), "LT_THETA"},
2539 {FIELD_OFFSET(D3DLIGHT9
, Phi
), "LT_PHI"}
2544 TRACE("LT_TYPE %u.\n", *(D3DLIGHTTYPE
*)value
);
2545 light
->Type
= *(D3DLIGHTTYPE
*)value
;
2551 D3DCOLORVALUE c
= *(D3DCOLORVALUE
*)value
;
2553 TRACE("%s (%f %f %f %f).\n", light_tbl
[op
].name
, c
.r
, c
.g
, c
.b
, c
.a
);
2554 *(D3DCOLORVALUE
*)((char *)light
+ light_tbl
[op
].offset
) = c
;
2560 D3DVECTOR v
= *(D3DVECTOR
*)value
;
2562 TRACE("%s (%f %f %f).\n", light_tbl
[op
].name
, v
.x
, v
.y
, v
.z
);
2563 *(D3DVECTOR
*)((char *)light
+ light_tbl
[op
].offset
) = v
;
2568 case LT_ATTENUATION0
:
2569 case LT_ATTENUATION1
:
2570 case LT_ATTENUATION2
:
2574 float v
= *(float *)value
;
2575 TRACE("%s %f.\n", light_tbl
[op
].name
, v
);
2576 *(float *)((char *)light
+ light_tbl
[op
].offset
) = v
;
2580 WARN("Unknown light parameter %u.\n", op
);
2585 static void d3dx9_set_material_parameter(enum MATERIAL_TYPE op
, D3DMATERIAL9
*material
, void *value
)
2589 unsigned int offset
;
2594 {FIELD_OFFSET(D3DMATERIAL9
, Diffuse
), "MT_DIFFUSE"},
2595 {FIELD_OFFSET(D3DMATERIAL9
, Ambient
), "MT_AMBIENT"},
2596 {FIELD_OFFSET(D3DMATERIAL9
, Specular
), "MT_SPECULAR"},
2597 {FIELD_OFFSET(D3DMATERIAL9
, Emissive
), "MT_EMISSIVE"},
2598 {FIELD_OFFSET(D3DMATERIAL9
, Power
), "MT_POWER"}
2605 float v
= *(float *)value
;
2607 TRACE("%s %f.\n", material_tbl
[op
].name
, v
);
2608 material
->Power
= v
;
2616 D3DCOLORVALUE c
= *(D3DCOLORVALUE
*)value
;
2618 TRACE("%s, value (%f %f %f %f).\n", material_tbl
[op
].name
, c
.r
, c
.g
, c
.b
, c
.a
);
2619 *(D3DCOLORVALUE
*)((char *)material
+ material_tbl
[op
].offset
) = c
;
2623 WARN("Unknown material parameter %u.\n", op
);
2628 static HRESULT
d3dx_set_shader_const_state(IDirect3DDevice9
*device
, enum SHADER_CONSTANT_TYPE op
, UINT index
,
2629 struct d3dx_parameter
*param
, void *value_ptr
)
2633 D3DXPARAMETER_TYPE type
;
2639 {D3DXPT_FLOAT
, sizeof(float) * 4, "SCT_VSFLOAT"},
2640 {D3DXPT_BOOL
, sizeof(BOOL
), "SCT_VSBOOL"},
2641 {D3DXPT_INT
, sizeof(int) * 4, "SCT_VSINT"},
2642 {D3DXPT_FLOAT
, sizeof(float) * 4, "SCT_PSFLOAT"},
2643 {D3DXPT_BOOL
, sizeof(BOOL
), "SCT_PSBOOL"},
2644 {D3DXPT_INT
, sizeof(int) * 4, "SCT_PSINT"},
2648 if (op
< 0 || op
> SCT_PSINT
)
2650 FIXME("Unknown op %u.\n", op
);
2651 return D3DERR_INVALIDCALL
;
2653 nelem
= param
->bytes
/ const_tbl
[op
].elem_size
;
2654 TRACE("%s, index %u, %u elements.\n", const_tbl
[op
].name
, index
, nelem
);
2655 if (param
->type
!= const_tbl
[op
].type
)
2657 FIXME("Unexpected param type %u.\n", param
->type
);
2658 return D3DERR_INVALIDCALL
;
2660 if (param
->bytes
% const_tbl
[op
].elem_size
!= 0)
2662 FIXME("Unexpected param size %u, rows %u, cols %u.\n", param
->bytes
, param
->rows
, param
->columns
);
2663 return D3DERR_INVALIDCALL
;
2669 return IDirect3DDevice9_SetVertexShaderConstantF(device
, index
, (const float *)value_ptr
, nelem
);
2671 return IDirect3DDevice9_SetVertexShaderConstantB(device
, index
, (const BOOL
*)value_ptr
, nelem
);
2673 return IDirect3DDevice9_SetVertexShaderConstantI(device
, index
, (const int *)value_ptr
, nelem
);
2675 return IDirect3DDevice9_SetPixelShaderConstantF(device
, index
, (const float *)value_ptr
, nelem
);
2677 return IDirect3DDevice9_SetPixelShaderConstantB(device
, index
, (const BOOL
*)value_ptr
, nelem
);
2679 return IDirect3DDevice9_SetPixelShaderConstantI(device
, index
, (const int *)value_ptr
, nelem
);
2684 static HRESULT
d3dx9_apply_state(struct ID3DXEffectImpl
*effect
, struct d3dx_pass
*pass
,
2685 struct d3dx_state
*state
, int parent_index
)
2687 IDirect3DDevice9
*device
= effect
->device
;
2688 struct d3dx_parameter
*param
;
2692 TRACE("operation %u, index %u, type %u.\n", state
->operation
, state
->index
, state
->type
);
2693 hr
= d3dx9_get_param_value_ptr(effect
, pass
, state
, ¶m_value
, ¶m
);
2697 switch (state_table
[state
->operation
].class)
2699 case SC_RENDERSTATE
:
2700 TRACE("%s, operation %u, value %u.\n", state_table
[state
->operation
].name
,
2701 state_table
[state
->operation
].op
, *(DWORD
*)param_value
);
2702 return IDirect3DDevice9_SetRenderState(device
, state_table
[state
->operation
].op
, *(DWORD
*)param_value
);
2704 TRACE("%s, value %#x.\n", state_table
[state
->operation
].name
, *(DWORD
*)param_value
);
2705 return IDirect3DDevice9_SetFVF(device
, *(DWORD
*)param_value
);
2710 unit
= parent_index
== -1 ? state
->index
: parent_index
;
2711 TRACE("%s, unit %u, value %p.\n", state_table
[state
->operation
].name
, unit
,
2712 *(IDirect3DBaseTexture9
**)param_value
);
2713 return IDirect3DDevice9_SetTexture(device
, unit
, *(IDirect3DBaseTexture9
**)param_value
);
2715 case SC_TEXTURESTAGE
:
2716 TRACE("%s, stage %u, value %u.\n", state_table
[state
->operation
].name
, state
->index
, *(DWORD
*)param_value
);
2717 return IDirect3DDevice9_SetTextureStageState(device
, state
->index
,
2718 state_table
[state
->operation
].op
, *(DWORD
*)param_value
);
2721 struct d3dx_sampler
*sampler
;
2725 sampler
= (struct d3dx_sampler
*)param_value
;
2726 TRACE("%s, sampler %u, applying %u states.\n", state_table
[state
->operation
].name
, state
->index
,
2727 sampler
->state_count
);
2729 for (i
= 0; i
< sampler
->state_count
; i
++)
2731 hr
= d3dx9_apply_state(effect
, pass
, &sampler
->states
[i
], state
->index
);
2737 case SC_SAMPLERSTATE
:
2741 sampler
= parent_index
== -1 ? state
->index
: parent_index
;
2742 TRACE("%s, sampler %u, value %u.\n", state_table
[state
->operation
].name
, sampler
, *(DWORD
*)param_value
);
2743 return IDirect3DDevice9_SetSamplerState(device
, sampler
, state_table
[state
->operation
].op
,
2744 *(DWORD
*)param_value
);
2746 case SC_VERTEXSHADER
:
2747 TRACE("%s, shader %p.\n", state_table
[state
->operation
].name
, *(IDirect3DVertexShader9
**)param_value
);
2748 hr
= IDirect3DDevice9_SetVertexShader(device
, *(IDirect3DVertexShader9
**)param_value
);
2750 ERR("Could not set vertex shader, hr %#x.\n", hr
);
2751 FIXME("Not executing preshader and not setting constants.\n");
2753 case SC_PIXELSHADER
:
2754 TRACE("%s, shader %p.\n", state_table
[state
->operation
].name
, *(IDirect3DPixelShader9
**)param_value
);
2755 hr
= IDirect3DDevice9_SetPixelShader(device
, *(IDirect3DPixelShader9
**)param_value
);
2757 ERR("Could not set pixel shader, hr %#x.\n", hr
);
2758 FIXME("Not executing preshader and not setting constants.\n");
2761 TRACE("%s, state %u.\n", state_table
[state
->operation
].name
, state
->index
);
2762 return IDirect3DDevice9_SetTransform(device
, state_table
[state
->operation
].op
+ state
->index
,
2763 (D3DMATRIX
*)param_value
);
2764 case SC_LIGHTENABLE
:
2765 TRACE("%s, index %u, value %u.\n", state_table
[state
->operation
].name
, state
->index
, *(BOOL
*)param_value
);
2766 return IDirect3DDevice9_LightEnable(device
, state
->index
, *(BOOL
*)param_value
);
2771 TRACE("%s, index %u, op %u.\n", state_table
[state
->operation
].name
, state
->index
,
2772 state_table
[state
->operation
].op
);
2773 hr
= IDirect3DDevice9_GetLight(device
, state
->index
, &light
);
2776 WARN("Could not get light, hr %#x.\n", hr
);
2777 memset(&light
, 0, sizeof(light
));
2779 d3dx9_set_light_parameter(state_table
[state
->operation
].op
, &light
, param_value
);
2780 return IDirect3DDevice9_SetLight(device
, state
->index
, &light
);
2784 D3DMATERIAL9 material
;
2786 TRACE("%s, index %u, op %u.\n", state_table
[state
->operation
].name
, state
->index
,
2787 state_table
[state
->operation
].op
);
2788 hr
= IDirect3DDevice9_GetMaterial(device
, &material
);
2791 WARN("Could not get material, hr %#x.\n", hr
);
2792 memset(&material
, 0, sizeof(material
));
2794 d3dx9_set_material_parameter(state_table
[state
->operation
].op
, &material
, param_value
);
2795 return IDirect3DDevice9_SetMaterial(device
, &material
);
2798 TRACE("%s, nsegments %f.\n", state_table
[state
->operation
].name
, *(float *)param_value
);
2799 return IDirect3DDevice9_SetNPatchMode(device
, *(float *)param_value
);
2800 case SC_SHADERCONST
:
2801 TRACE("%s, index %u, op %u.\n", state_table
[state
->operation
].name
, state
->index
,
2802 state_table
[state
->operation
].op
);
2803 return d3dx_set_shader_const_state(device
, state_table
[state
->operation
].op
, state
->index
,
2804 param
, param_value
);
2806 FIXME("%s not handled.\n", state_table
[state
->operation
].name
);
2812 static HRESULT
d3dx9_apply_pass_states(struct ID3DXEffectImpl
*effect
, struct d3dx_pass
*pass
)
2817 TRACE("effect %p, pass %p, state_count %u.\n", effect
, pass
, pass
->state_count
);
2820 for (i
= 0; i
< pass
->state_count
; i
++)
2824 hr
= d3dx9_apply_state(effect
, pass
, &pass
->states
[i
], -1);
2827 WARN("Error applying state, hr %#x.\n", hr
);
2834 static inline struct ID3DXEffectImpl
*impl_from_ID3DXEffect(ID3DXEffect
*iface
)
2836 return CONTAINING_RECORD(iface
, struct ID3DXEffectImpl
, ID3DXEffect_iface
);
2839 /*** IUnknown methods ***/
2840 static HRESULT WINAPI
ID3DXEffectImpl_QueryInterface(ID3DXEffect
*iface
, REFIID riid
, void **object
)
2842 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), object
);
2844 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
2845 IsEqualGUID(riid
, &IID_ID3DXEffect
))
2847 iface
->lpVtbl
->AddRef(iface
);
2852 ERR("Interface %s not found\n", debugstr_guid(riid
));
2854 return E_NOINTERFACE
;
2857 static ULONG WINAPI
ID3DXEffectImpl_AddRef(ID3DXEffect
*iface
)
2859 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2861 TRACE("(%p)->(): AddRef from %u\n", This
, This
->ref
);
2863 return InterlockedIncrement(&This
->ref
);
2866 static ULONG WINAPI
ID3DXEffectImpl_Release(ID3DXEffect
*iface
)
2868 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2869 ULONG ref
= InterlockedDecrement(&This
->ref
);
2871 TRACE("(%p)->(): Release from %u\n", This
, ref
+ 1);
2876 HeapFree(GetProcessHeap(), 0, This
);
2882 /*** ID3DXBaseEffect methods ***/
2883 static HRESULT WINAPI
ID3DXEffectImpl_GetDesc(ID3DXEffect
*iface
, D3DXEFFECT_DESC
*desc
)
2885 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2887 TRACE("iface %p, desc %p.\n", iface
, desc
);
2889 return d3dx9_base_effect_get_desc(&effect
->base_effect
, desc
);
2892 static HRESULT WINAPI
ID3DXEffectImpl_GetParameterDesc(ID3DXEffect
*iface
,
2893 D3DXHANDLE parameter
, D3DXPARAMETER_DESC
*desc
)
2895 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2897 TRACE("iface %p, parameter %p, desc %p.\n", iface
, parameter
, desc
);
2899 return d3dx9_base_effect_get_parameter_desc(&effect
->base_effect
, parameter
, desc
);
2902 static HRESULT WINAPI
ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect
*iface
,
2903 D3DXHANDLE technique
, D3DXTECHNIQUE_DESC
*desc
)
2905 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2907 TRACE("iface %p, technique %p, desc %p.\n", iface
, technique
, desc
);
2909 return d3dx9_base_effect_get_technique_desc(&effect
->base_effect
, technique
, desc
);
2912 static HRESULT WINAPI
ID3DXEffectImpl_GetPassDesc(ID3DXEffect
*iface
, D3DXHANDLE pass
, D3DXPASS_DESC
*desc
)
2914 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2916 TRACE("iface %p, pass %p, desc %p.\n", iface
, pass
, desc
);
2918 return d3dx9_base_effect_get_pass_desc(&effect
->base_effect
, pass
, desc
);
2921 static HRESULT WINAPI
ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect
*iface
, D3DXHANDLE shader
, D3DXFUNCTION_DESC
*desc
)
2923 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2925 TRACE("iface %p, shader %p, desc %p.\n", iface
, shader
, desc
);
2927 return d3dx9_base_effect_get_function_desc(&effect
->base_effect
, shader
, desc
);
2930 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameter(ID3DXEffect
*iface
, D3DXHANDLE parameter
, UINT index
)
2932 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2934 TRACE("iface %p, parameter %p, index %u.\n", iface
, parameter
, index
);
2936 return d3dx9_base_effect_get_parameter(&effect
->base_effect
, parameter
, index
);
2939 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameterByName(ID3DXEffect
*iface
,
2940 D3DXHANDLE parameter
, const char *name
)
2942 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2944 TRACE("iface %p, parameter %p, name %s.\n", iface
, parameter
, debugstr_a(name
));
2946 return d3dx9_base_effect_get_parameter_by_name(&effect
->base_effect
, parameter
, name
);
2949 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect
*iface
,
2950 D3DXHANDLE parameter
, const char *semantic
)
2952 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2954 TRACE("iface %p, parameter %p, semantic %s.\n", iface
, parameter
, debugstr_a(semantic
));
2956 return d3dx9_base_effect_get_parameter_by_semantic(&effect
->base_effect
, parameter
, semantic
);
2959 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameterElement(ID3DXEffect
*iface
, D3DXHANDLE parameter
, UINT index
)
2961 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2963 TRACE("iface %p, parameter %p, index %u.\n", iface
, parameter
, index
);
2965 return d3dx9_base_effect_get_parameter_element(&effect
->base_effect
, parameter
, index
);
2968 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetTechnique(ID3DXEffect
*iface
, UINT index
)
2970 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2972 TRACE("iface %p, index %u.\n", iface
, index
);
2974 return d3dx9_base_effect_get_technique(&effect
->base_effect
, index
);
2977 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect
*iface
, const char *name
)
2979 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2981 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
2983 return d3dx9_base_effect_get_technique_by_name(&effect
->base_effect
, name
);
2986 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetPass(ID3DXEffect
*iface
, D3DXHANDLE technique
, UINT index
)
2988 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2990 TRACE("iface %p, technique %p, index %u.\n", iface
, technique
, index
);
2992 return d3dx9_base_effect_get_pass(&effect
->base_effect
, technique
, index
);
2995 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetPassByName(ID3DXEffect
*iface
,
2996 D3DXHANDLE technique
, const char *name
)
2998 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3000 TRACE("iface %p, technique %p, name %s.\n", iface
, technique
, debugstr_a(name
));
3002 return d3dx9_base_effect_get_pass_by_name(&effect
->base_effect
, technique
, name
);
3005 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetFunction(ID3DXEffect
*iface
, UINT index
)
3007 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3009 TRACE("iface %p, index %u.\n", iface
, index
);
3011 return d3dx9_base_effect_get_function(&effect
->base_effect
, index
);
3014 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetFunctionByName(ID3DXEffect
*iface
, const char *name
)
3016 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3018 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
3020 return d3dx9_base_effect_get_function_by_name(&effect
->base_effect
, name
);
3023 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetAnnotation(ID3DXEffect
*iface
, D3DXHANDLE object
, UINT index
)
3025 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3027 TRACE("iface %p, object %p, index %u.\n", iface
, object
, index
);
3029 return d3dx9_base_effect_get_annotation(&effect
->base_effect
, object
, index
);
3032 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect
*iface
,
3033 D3DXHANDLE object
, const char *name
)
3035 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3037 TRACE("iface %p, object %p, name %s.\n", iface
, object
, debugstr_a(name
));
3039 return d3dx9_base_effect_get_annotation_by_name(&effect
->base_effect
, object
, name
);
3042 static HRESULT WINAPI
ID3DXEffectImpl_SetValue(ID3DXEffect
*iface
,
3043 D3DXHANDLE parameter
, const void *data
, UINT bytes
)
3045 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3047 TRACE("iface %p, parameter %p, data %p, bytes %u.\n", iface
, parameter
, data
, bytes
);
3049 return d3dx9_base_effect_set_value(&effect
->base_effect
, parameter
, data
, bytes
);
3052 static HRESULT WINAPI
ID3DXEffectImpl_GetValue(ID3DXEffect
*iface
,
3053 D3DXHANDLE parameter
, void *data
, UINT bytes
)
3055 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3057 TRACE("iface %p, parameter %p, data %p, bytes %u.\n", iface
, parameter
, data
, bytes
);
3059 return d3dx9_base_effect_get_value(&effect
->base_effect
, parameter
, data
, bytes
);
3062 static HRESULT WINAPI
ID3DXEffectImpl_SetBool(ID3DXEffect
*iface
, D3DXHANDLE parameter
, BOOL b
)
3064 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3066 TRACE("iface %p, parameter %p, b %#x.\n", iface
, parameter
, b
);
3068 return d3dx9_base_effect_set_bool(&effect
->base_effect
, parameter
, b
);
3071 static HRESULT WINAPI
ID3DXEffectImpl_GetBool(ID3DXEffect
*iface
, D3DXHANDLE parameter
, BOOL
*b
)
3073 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3075 TRACE("iface %p, parameter %p, b %p.\n", iface
, parameter
, b
);
3077 return d3dx9_base_effect_get_bool(&effect
->base_effect
, parameter
, b
);
3080 static HRESULT WINAPI
ID3DXEffectImpl_SetBoolArray(ID3DXEffect
*iface
,
3081 D3DXHANDLE parameter
, const BOOL
*b
, UINT count
)
3083 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3085 TRACE("iface %p, parameter %p, b %p, count %u.\n", iface
, parameter
, b
, count
);
3087 return d3dx9_base_effect_set_bool_array(&effect
->base_effect
, parameter
, b
, count
);
3090 static HRESULT WINAPI
ID3DXEffectImpl_GetBoolArray(ID3DXEffect
*iface
,
3091 D3DXHANDLE parameter
, BOOL
*b
, UINT count
)
3093 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3095 TRACE("iface %p, parameter %p, b %p, count %u.\n", iface
, parameter
, b
, count
);
3097 return d3dx9_base_effect_get_bool_array(&effect
->base_effect
, parameter
, b
, count
);
3100 static HRESULT WINAPI
ID3DXEffectImpl_SetInt(ID3DXEffect
*iface
, D3DXHANDLE parameter
, INT n
)
3102 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3104 TRACE("iface %p, parameter %p, n %d.\n", iface
, parameter
, n
);
3106 return d3dx9_base_effect_set_int(&effect
->base_effect
, parameter
, n
);
3109 static HRESULT WINAPI
ID3DXEffectImpl_GetInt(ID3DXEffect
*iface
, D3DXHANDLE parameter
, INT
*n
)
3111 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3113 TRACE("iface %p, parameter %p, n %p.\n", iface
, parameter
, n
);
3115 return d3dx9_base_effect_get_int(&effect
->base_effect
, parameter
, n
);
3118 static HRESULT WINAPI
ID3DXEffectImpl_SetIntArray(ID3DXEffect
*iface
,
3119 D3DXHANDLE parameter
, const INT
*n
, UINT count
)
3121 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3123 TRACE("iface %p, parameter %p, n %p, count %u.\n", iface
, parameter
, n
, count
);
3125 return d3dx9_base_effect_set_int_array(&effect
->base_effect
, parameter
, n
, count
);
3128 static HRESULT WINAPI
ID3DXEffectImpl_GetIntArray(ID3DXEffect
*iface
,
3129 D3DXHANDLE parameter
, INT
*n
, UINT count
)
3131 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3133 TRACE("iface %p, parameter %p, n %p, count %u.\n", iface
, parameter
, n
, count
);
3135 return d3dx9_base_effect_get_int_array(&effect
->base_effect
, parameter
, n
, count
);
3138 static HRESULT WINAPI
ID3DXEffectImpl_SetFloat(ID3DXEffect
*iface
, D3DXHANDLE parameter
, float f
)
3140 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3142 TRACE("iface %p, parameter %p, f %.8e.\n", iface
, parameter
, f
);
3144 return d3dx9_base_effect_set_float(&effect
->base_effect
, parameter
, f
);
3147 static HRESULT WINAPI
ID3DXEffectImpl_GetFloat(ID3DXEffect
*iface
, D3DXHANDLE parameter
, float *f
)
3149 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3151 TRACE("iface %p, parameter %p, f %p.\n", iface
, parameter
, f
);
3153 return d3dx9_base_effect_get_float(&effect
->base_effect
, parameter
, f
);
3156 static HRESULT WINAPI
ID3DXEffectImpl_SetFloatArray(ID3DXEffect
*iface
,
3157 D3DXHANDLE parameter
, const float *f
, UINT count
)
3159 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3161 TRACE("iface %p, parameter %p, f %p, count %u.\n", iface
, parameter
, f
, count
);
3163 return d3dx9_base_effect_set_float_array(&effect
->base_effect
, parameter
, f
, count
);
3166 static HRESULT WINAPI
ID3DXEffectImpl_GetFloatArray(ID3DXEffect
*iface
,
3167 D3DXHANDLE parameter
, float *f
, UINT count
)
3169 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3171 TRACE("iface %p, parameter %p, f %p, count %u.\n", iface
, parameter
, f
, count
);
3173 return d3dx9_base_effect_get_float_array(&effect
->base_effect
, parameter
, f
, count
);
3176 static HRESULT WINAPI
ID3DXEffectImpl_SetVector(ID3DXEffect
*iface
,
3177 D3DXHANDLE parameter
, const D3DXVECTOR4
*vector
)
3179 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3181 TRACE("iface %p, parameter %p, vector %p.\n", iface
, parameter
, vector
);
3183 return d3dx9_base_effect_set_vector(&effect
->base_effect
, parameter
, vector
);
3186 static HRESULT WINAPI
ID3DXEffectImpl_GetVector(ID3DXEffect
*iface
,
3187 D3DXHANDLE parameter
, D3DXVECTOR4
*vector
)
3189 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3191 TRACE("iface %p, parameter %p, vector %p.\n", iface
, parameter
, vector
);
3193 return d3dx9_base_effect_get_vector(&effect
->base_effect
, parameter
, vector
);
3196 static HRESULT WINAPI
ID3DXEffectImpl_SetVectorArray(ID3DXEffect
*iface
,
3197 D3DXHANDLE parameter
, const D3DXVECTOR4
*vector
, UINT count
)
3199 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3201 TRACE("iface %p, parameter %p, vector %p, count %u.\n", iface
, parameter
, vector
, count
);
3203 return d3dx9_base_effect_set_vector_array(&effect
->base_effect
, parameter
, vector
, count
);
3206 static HRESULT WINAPI
ID3DXEffectImpl_GetVectorArray(ID3DXEffect
*iface
,
3207 D3DXHANDLE parameter
, D3DXVECTOR4
*vector
, UINT count
)
3209 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3211 TRACE("iface %p, parameter %p, vector %p, count %u.\n", iface
, parameter
, vector
, count
);
3213 return d3dx9_base_effect_get_vector_array(&effect
->base_effect
, parameter
, vector
, count
);
3216 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrix(ID3DXEffect
*iface
,
3217 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
)
3219 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3221 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
3223 return d3dx9_base_effect_set_matrix(&effect
->base_effect
, parameter
, matrix
);
3226 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrix(ID3DXEffect
*iface
,
3227 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
3229 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3231 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
3233 return d3dx9_base_effect_get_matrix(&effect
->base_effect
, parameter
, matrix
);
3236 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixArray(ID3DXEffect
*iface
,
3237 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
, UINT count
)
3239 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3241 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3243 return d3dx9_base_effect_set_matrix_array(&effect
->base_effect
, parameter
, matrix
, count
);
3246 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixArray(ID3DXEffect
*iface
,
3247 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
3249 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3251 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3253 return d3dx9_base_effect_get_matrix_array(&effect
->base_effect
, parameter
, matrix
, count
);
3256 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect
*iface
,
3257 D3DXHANDLE parameter
, const D3DXMATRIX
**matrix
, UINT count
)
3259 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3261 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3263 return d3dx9_base_effect_set_matrix_pointer_array(&effect
->base_effect
, parameter
, matrix
, count
);
3266 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect
*iface
,
3267 D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
3269 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3271 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3273 return d3dx9_base_effect_get_matrix_pointer_array(&effect
->base_effect
, parameter
, matrix
, count
);
3276 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect
*iface
,
3277 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
)
3279 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3281 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
3283 return d3dx9_base_effect_set_matrix_transpose(&effect
->base_effect
, parameter
, matrix
);
3286 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect
*iface
,
3287 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
3289 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3291 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
3293 return d3dx9_base_effect_get_matrix_transpose(&effect
->base_effect
, parameter
, matrix
);
3296 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect
*iface
,
3297 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
, UINT count
)
3299 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3301 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3303 return d3dx9_base_effect_set_matrix_transpose_array(&effect
->base_effect
, parameter
, matrix
, count
);
3306 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect
*iface
,
3307 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
3309 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3311 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3313 return d3dx9_base_effect_get_matrix_transpose_array(&effect
->base_effect
, parameter
, matrix
, count
);
3316 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect
*iface
,
3317 D3DXHANDLE parameter
, const D3DXMATRIX
**matrix
, UINT count
)
3319 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3321 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3323 return d3dx9_base_effect_set_matrix_transpose_pointer_array(&effect
->base_effect
, parameter
, matrix
, count
);
3326 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect
*iface
,
3327 D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
3329 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3331 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3333 return d3dx9_base_effect_get_matrix_transpose_pointer_array(&effect
->base_effect
, parameter
, matrix
, count
);
3336 static HRESULT WINAPI
ID3DXEffectImpl_SetString(ID3DXEffect
*iface
, D3DXHANDLE parameter
, const char *string
)
3338 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3340 TRACE("iface %p, parameter %p, string %s.\n", iface
, parameter
, debugstr_a(string
));
3342 return d3dx9_base_effect_set_string(&effect
->base_effect
, parameter
, string
);
3345 static HRESULT WINAPI
ID3DXEffectImpl_GetString(ID3DXEffect
*iface
, D3DXHANDLE parameter
, const char **string
)
3347 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3349 TRACE("iface %p, parameter %p, string %p.\n", iface
, parameter
, string
);
3351 return d3dx9_base_effect_get_string(&effect
->base_effect
, parameter
, string
);
3354 static HRESULT WINAPI
ID3DXEffectImpl_SetTexture(struct ID3DXEffect
*iface
,
3355 D3DXHANDLE parameter
, struct IDirect3DBaseTexture9
*texture
)
3357 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3359 TRACE("iface %p, parameter %p, texture %p.\n", iface
, parameter
, texture
);
3361 return d3dx9_base_effect_set_texture(&effect
->base_effect
, parameter
, texture
);
3364 static HRESULT WINAPI
ID3DXEffectImpl_GetTexture(struct ID3DXEffect
*iface
,
3365 D3DXHANDLE parameter
, struct IDirect3DBaseTexture9
**texture
)
3367 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3369 TRACE("iface %p, parameter %p, texture %p.\n", iface
, parameter
, texture
);
3371 return d3dx9_base_effect_get_texture(&effect
->base_effect
, parameter
, texture
);
3374 static HRESULT WINAPI
ID3DXEffectImpl_GetPixelShader(ID3DXEffect
*iface
,
3375 D3DXHANDLE parameter
, struct IDirect3DPixelShader9
**shader
)
3377 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3379 TRACE("iface %p, parameter %p, shader %p.\n", iface
, parameter
, shader
);
3381 return d3dx9_base_effect_get_pixel_shader(&effect
->base_effect
, parameter
, shader
);
3384 static HRESULT WINAPI
ID3DXEffectImpl_GetVertexShader(struct ID3DXEffect
*iface
,
3385 D3DXHANDLE parameter
, struct IDirect3DVertexShader9
**shader
)
3387 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3389 TRACE("iface %p, parameter %p, shader %p.\n", iface
, parameter
, shader
);
3391 return d3dx9_base_effect_get_vertex_shader(&effect
->base_effect
, parameter
, shader
);
3394 static HRESULT WINAPI
ID3DXEffectImpl_SetArrayRange(ID3DXEffect
*iface
, D3DXHANDLE parameter
, UINT start
, UINT end
)
3396 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3398 TRACE("iface %p, parameter %p, start %u, end %u.\n", iface
, parameter
, start
, end
);
3400 return d3dx9_base_effect_set_array_range(&effect
->base_effect
, parameter
, start
, end
);
3403 /*** ID3DXEffect methods ***/
3404 static HRESULT WINAPI
ID3DXEffectImpl_GetPool(ID3DXEffect
*iface
, ID3DXEffectPool
**pool
)
3406 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3408 TRACE("iface %p, pool %p\n", This
, pool
);
3412 WARN("Invalid argument supplied.\n");
3413 return D3DERR_INVALIDCALL
;
3418 This
->pool
->lpVtbl
->AddRef(This
->pool
);
3423 TRACE("Returning pool %p\n", *pool
);
3428 static HRESULT WINAPI
ID3DXEffectImpl_SetTechnique(ID3DXEffect
*iface
, D3DXHANDLE technique
)
3430 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3431 struct d3dx9_base_effect
*base
= &This
->base_effect
;
3432 struct d3dx_technique
*tech
= get_valid_technique(base
, technique
);
3434 TRACE("iface %p, technique %p\n", This
, technique
);
3438 This
->active_technique
= tech
;
3439 TRACE("Technique %p\n", tech
);
3443 WARN("Technique not found.\n");
3445 return D3DERR_INVALIDCALL
;
3448 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect
*iface
)
3450 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3452 TRACE("iface %p\n", This
);
3454 return get_technique_handle(This
->active_technique
);
3457 static HRESULT WINAPI
ID3DXEffectImpl_ValidateTechnique(ID3DXEffect
* iface
, D3DXHANDLE technique
)
3459 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3461 FIXME("(%p)->(%p): stub\n", This
, technique
);
3466 static HRESULT WINAPI
ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect
* iface
, D3DXHANDLE technique
, D3DXHANDLE
* next_technique
)
3468 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3470 FIXME("(%p)->(%p, %p): stub\n", This
, technique
, next_technique
);
3475 static BOOL WINAPI
ID3DXEffectImpl_IsParameterUsed(ID3DXEffect
* iface
, D3DXHANDLE parameter
, D3DXHANDLE technique
)
3477 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3478 struct d3dx_parameter
*param
= get_valid_parameter(&effect
->base_effect
, parameter
);
3480 FIXME("iface %p, parameter %p, technique %p stub.\n", iface
, parameter
, technique
);
3481 TRACE("param %p (%s).\n", param
, param
? debugstr_a(param
->name
) : "");
3486 static HRESULT WINAPI
ID3DXEffectImpl_Begin(ID3DXEffect
*iface
, UINT
*passes
, DWORD flags
)
3488 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3489 struct d3dx_technique
*technique
= effect
->active_technique
;
3491 TRACE("iface %p, passes %p, flags %#x.\n", iface
, passes
, flags
);
3493 if (passes
&& technique
)
3495 if (flags
& ~(D3DXFX_DONOTSAVESTATE
| D3DXFX_DONOTSAVESAMPLERSTATE
| D3DXFX_DONOTSAVESHADERSTATE
))
3496 WARN("Invalid flags (%#x) specified.\n", flags
);
3498 if (effect
->manager
|| flags
& D3DXFX_DONOTSAVESTATE
)
3500 TRACE("State capturing disabled.\n");
3507 if (!technique
->saved_state
)
3509 hr
= IDirect3DDevice9_BeginStateBlock(effect
->device
);
3511 ERR("BeginStateBlock failed, hr %#x.\n", hr
);
3512 for (i
= 0; i
< technique
->pass_count
; i
++)
3513 d3dx9_apply_pass_states(effect
, &technique
->passes
[i
]);
3514 hr
= IDirect3DDevice9_EndStateBlock(effect
->device
, &technique
->saved_state
);
3516 ERR("EndStateBlock failed, hr %#x.\n", hr
);
3518 hr
= IDirect3DStateBlock9_Capture(technique
->saved_state
);
3520 ERR("StateBlock Capture failed, hr %#x.\n", hr
);
3523 *passes
= technique
->pass_count
;
3524 effect
->started
= TRUE
;
3525 effect
->flags
= flags
;
3530 WARN("Invalid argument supplied.\n");
3532 return D3DERR_INVALIDCALL
;
3535 static HRESULT WINAPI
ID3DXEffectImpl_BeginPass(ID3DXEffect
*iface
, UINT pass
)
3537 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3538 struct d3dx_technique
*technique
= effect
->active_technique
;
3540 TRACE("iface %p, pass %u\n", effect
, pass
);
3542 if (technique
&& pass
< technique
->pass_count
&& !effect
->active_pass
)
3544 effect
->active_pass
= &technique
->passes
[pass
];
3545 return d3dx9_apply_pass_states(effect
, effect
->active_pass
);
3548 WARN("Invalid argument supplied.\n");
3550 return D3DERR_INVALIDCALL
;
3553 static HRESULT WINAPI
ID3DXEffectImpl_CommitChanges(ID3DXEffect
*iface
)
3555 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3557 TRACE("iface %p.\n", iface
);
3559 if (!effect
->active_pass
)
3561 WARN("Called without an active pass.\n");
3564 /* TODO: apply only changed states */
3565 return d3dx9_apply_pass_states(effect
, effect
->active_pass
);
3568 static HRESULT WINAPI
ID3DXEffectImpl_EndPass(ID3DXEffect
*iface
)
3570 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3572 TRACE("iface %p\n", This
);
3574 if (This
->active_pass
)
3576 This
->active_pass
= NULL
;
3580 WARN("Invalid call.\n");
3582 return D3DERR_INVALIDCALL
;
3585 static HRESULT WINAPI
ID3DXEffectImpl_End(ID3DXEffect
*iface
)
3587 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3588 struct d3dx_technique
*technique
= effect
->active_technique
;
3590 TRACE("iface %p.\n", iface
);
3592 if (!effect
->started
)
3595 if (effect
->manager
|| effect
->flags
& D3DXFX_DONOTSAVESTATE
)
3597 TRACE("State restoring disabled.\n");
3603 if (technique
&& technique
->saved_state
)
3605 hr
= IDirect3DStateBlock9_Apply(technique
->saved_state
);
3607 ERR("State block apply failed, hr %#x.\n", hr
);
3610 ERR("No saved state.\n");
3613 effect
->started
= FALSE
;
3618 static HRESULT WINAPI
ID3DXEffectImpl_GetDevice(ID3DXEffect
*iface
, struct IDirect3DDevice9
**device
)
3620 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3622 TRACE("iface %p, device %p\n", This
, device
);
3626 WARN("Invalid argument supplied.\n");
3627 return D3DERR_INVALIDCALL
;
3630 IDirect3DDevice9_AddRef(This
->device
);
3632 *device
= This
->device
;
3634 TRACE("Returning device %p\n", *device
);
3639 static HRESULT WINAPI
ID3DXEffectImpl_OnLostDevice(ID3DXEffect
* iface
)
3641 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3643 FIXME("(%p)->(): stub\n", This
);
3648 static HRESULT WINAPI
ID3DXEffectImpl_OnResetDevice(ID3DXEffect
* iface
)
3650 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3652 FIXME("(%p)->(): stub\n", This
);
3657 static HRESULT WINAPI
ID3DXEffectImpl_SetStateManager(ID3DXEffect
*iface
, ID3DXEffectStateManager
*manager
)
3659 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3661 TRACE("iface %p, manager %p\n", This
, manager
);
3663 if (manager
) IUnknown_AddRef(manager
);
3664 if (This
->manager
) IUnknown_Release(This
->manager
);
3666 This
->manager
= manager
;
3671 static HRESULT WINAPI
ID3DXEffectImpl_GetStateManager(ID3DXEffect
*iface
, ID3DXEffectStateManager
**manager
)
3673 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3675 TRACE("iface %p, manager %p\n", This
, manager
);
3679 WARN("Invalid argument supplied.\n");
3680 return D3DERR_INVALIDCALL
;
3683 if (This
->manager
) IUnknown_AddRef(This
->manager
);
3684 *manager
= This
->manager
;
3689 static HRESULT WINAPI
ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect
* iface
)
3691 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3693 FIXME("(%p)->(): stub\n", This
);
3698 static D3DXHANDLE WINAPI
ID3DXEffectImpl_EndParameterBlock(ID3DXEffect
* iface
)
3700 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3702 FIXME("(%p)->(): stub\n", This
);
3707 static HRESULT WINAPI
ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect
* iface
, D3DXHANDLE parameter_block
)
3709 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3711 FIXME("(%p)->(%p): stub\n", This
, parameter_block
);
3716 static HRESULT WINAPI
ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect
* iface
, D3DXHANDLE parameter_block
)
3718 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3720 FIXME("(%p)->(%p): stub\n", This
, parameter_block
);
3725 static HRESULT WINAPI
ID3DXEffectImpl_CloneEffect(ID3DXEffect
*iface
,
3726 struct IDirect3DDevice9
*device
, struct ID3DXEffect
**effect
)
3728 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3730 FIXME("(%p)->(%p, %p): stub\n", This
, device
, effect
);
3735 static HRESULT WINAPI
ID3DXEffectImpl_SetRawValue(ID3DXEffect
*iface
,
3736 D3DXHANDLE parameter
, const void *data
, UINT byte_offset
, UINT bytes
)
3738 FIXME("iface %p, parameter %p, data %p, byte_offset %u, bytes %u stub!\n",
3739 iface
, parameter
, data
, byte_offset
, bytes
);
3744 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl
=
3746 /*** IUnknown methods ***/
3747 ID3DXEffectImpl_QueryInterface
,
3748 ID3DXEffectImpl_AddRef
,
3749 ID3DXEffectImpl_Release
,
3750 /*** ID3DXBaseEffect methods ***/
3751 ID3DXEffectImpl_GetDesc
,
3752 ID3DXEffectImpl_GetParameterDesc
,
3753 ID3DXEffectImpl_GetTechniqueDesc
,
3754 ID3DXEffectImpl_GetPassDesc
,
3755 ID3DXEffectImpl_GetFunctionDesc
,
3756 ID3DXEffectImpl_GetParameter
,
3757 ID3DXEffectImpl_GetParameterByName
,
3758 ID3DXEffectImpl_GetParameterBySemantic
,
3759 ID3DXEffectImpl_GetParameterElement
,
3760 ID3DXEffectImpl_GetTechnique
,
3761 ID3DXEffectImpl_GetTechniqueByName
,
3762 ID3DXEffectImpl_GetPass
,
3763 ID3DXEffectImpl_GetPassByName
,
3764 ID3DXEffectImpl_GetFunction
,
3765 ID3DXEffectImpl_GetFunctionByName
,
3766 ID3DXEffectImpl_GetAnnotation
,
3767 ID3DXEffectImpl_GetAnnotationByName
,
3768 ID3DXEffectImpl_SetValue
,
3769 ID3DXEffectImpl_GetValue
,
3770 ID3DXEffectImpl_SetBool
,
3771 ID3DXEffectImpl_GetBool
,
3772 ID3DXEffectImpl_SetBoolArray
,
3773 ID3DXEffectImpl_GetBoolArray
,
3774 ID3DXEffectImpl_SetInt
,
3775 ID3DXEffectImpl_GetInt
,
3776 ID3DXEffectImpl_SetIntArray
,
3777 ID3DXEffectImpl_GetIntArray
,
3778 ID3DXEffectImpl_SetFloat
,
3779 ID3DXEffectImpl_GetFloat
,
3780 ID3DXEffectImpl_SetFloatArray
,
3781 ID3DXEffectImpl_GetFloatArray
,
3782 ID3DXEffectImpl_SetVector
,
3783 ID3DXEffectImpl_GetVector
,
3784 ID3DXEffectImpl_SetVectorArray
,
3785 ID3DXEffectImpl_GetVectorArray
,
3786 ID3DXEffectImpl_SetMatrix
,
3787 ID3DXEffectImpl_GetMatrix
,
3788 ID3DXEffectImpl_SetMatrixArray
,
3789 ID3DXEffectImpl_GetMatrixArray
,
3790 ID3DXEffectImpl_SetMatrixPointerArray
,
3791 ID3DXEffectImpl_GetMatrixPointerArray
,
3792 ID3DXEffectImpl_SetMatrixTranspose
,
3793 ID3DXEffectImpl_GetMatrixTranspose
,
3794 ID3DXEffectImpl_SetMatrixTransposeArray
,
3795 ID3DXEffectImpl_GetMatrixTransposeArray
,
3796 ID3DXEffectImpl_SetMatrixTransposePointerArray
,
3797 ID3DXEffectImpl_GetMatrixTransposePointerArray
,
3798 ID3DXEffectImpl_SetString
,
3799 ID3DXEffectImpl_GetString
,
3800 ID3DXEffectImpl_SetTexture
,
3801 ID3DXEffectImpl_GetTexture
,
3802 ID3DXEffectImpl_GetPixelShader
,
3803 ID3DXEffectImpl_GetVertexShader
,
3804 ID3DXEffectImpl_SetArrayRange
,
3805 /*** ID3DXEffect methods ***/
3806 ID3DXEffectImpl_GetPool
,
3807 ID3DXEffectImpl_SetTechnique
,
3808 ID3DXEffectImpl_GetCurrentTechnique
,
3809 ID3DXEffectImpl_ValidateTechnique
,
3810 ID3DXEffectImpl_FindNextValidTechnique
,
3811 ID3DXEffectImpl_IsParameterUsed
,
3812 ID3DXEffectImpl_Begin
,
3813 ID3DXEffectImpl_BeginPass
,
3814 ID3DXEffectImpl_CommitChanges
,
3815 ID3DXEffectImpl_EndPass
,
3816 ID3DXEffectImpl_End
,
3817 ID3DXEffectImpl_GetDevice
,
3818 ID3DXEffectImpl_OnLostDevice
,
3819 ID3DXEffectImpl_OnResetDevice
,
3820 ID3DXEffectImpl_SetStateManager
,
3821 ID3DXEffectImpl_GetStateManager
,
3822 ID3DXEffectImpl_BeginParameterBlock
,
3823 ID3DXEffectImpl_EndParameterBlock
,
3824 ID3DXEffectImpl_ApplyParameterBlock
,
3825 ID3DXEffectImpl_DeleteParameterBlock
,
3826 ID3DXEffectImpl_CloneEffect
,
3827 ID3DXEffectImpl_SetRawValue
3830 static inline struct ID3DXEffectCompilerImpl
*impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler
*iface
)
3832 return CONTAINING_RECORD(iface
, struct ID3DXEffectCompilerImpl
, ID3DXEffectCompiler_iface
);
3835 /*** IUnknown methods ***/
3836 static HRESULT WINAPI
ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler
*iface
, REFIID riid
, void **object
)
3838 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), object
);
3840 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
3841 IsEqualGUID(riid
, &IID_ID3DXEffectCompiler
))
3843 iface
->lpVtbl
->AddRef(iface
);
3848 ERR("Interface %s not found\n", debugstr_guid(riid
));
3850 return E_NOINTERFACE
;
3853 static ULONG WINAPI
ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler
*iface
)
3855 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3857 TRACE("iface %p: AddRef from %u\n", iface
, This
->ref
);
3859 return InterlockedIncrement(&This
->ref
);
3862 static ULONG WINAPI
ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler
*iface
)
3864 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3865 ULONG ref
= InterlockedDecrement(&This
->ref
);
3867 TRACE("iface %p: Release from %u\n", iface
, ref
+ 1);
3871 free_effect_compiler(This
);
3872 HeapFree(GetProcessHeap(), 0, This
);
3878 /*** ID3DXBaseEffect methods ***/
3879 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler
*iface
, D3DXEFFECT_DESC
*desc
)
3881 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3883 TRACE("iface %p, desc %p.\n", iface
, desc
);
3885 return d3dx9_base_effect_get_desc(&compiler
->base_effect
, desc
);
3888 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler
*iface
,
3889 D3DXHANDLE parameter
, D3DXPARAMETER_DESC
*desc
)
3891 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3893 TRACE("iface %p, parameter %p, desc %p.\n", iface
, parameter
, desc
);
3895 return d3dx9_base_effect_get_parameter_desc(&compiler
->base_effect
, parameter
, desc
);
3898 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler
*iface
,
3899 D3DXHANDLE technique
, D3DXTECHNIQUE_DESC
*desc
)
3901 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3903 TRACE("iface %p, technique %p, desc %p.\n", iface
, technique
, desc
);
3905 return d3dx9_base_effect_get_technique_desc(&compiler
->base_effect
, technique
, desc
);
3908 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler
*iface
,
3909 D3DXHANDLE pass
, D3DXPASS_DESC
*desc
)
3911 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3913 TRACE("iface %p, pass %p, desc %p.\n", iface
, pass
, desc
);
3915 return d3dx9_base_effect_get_pass_desc(&compiler
->base_effect
, pass
, desc
);
3918 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler
*iface
,
3919 D3DXHANDLE shader
, D3DXFUNCTION_DESC
*desc
)
3921 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3923 TRACE("iface %p, shader %p, desc %p.\n", iface
, shader
, desc
);
3925 return d3dx9_base_effect_get_function_desc(&compiler
->base_effect
, shader
, desc
);
3928 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler
*iface
,
3929 D3DXHANDLE parameter
, UINT index
)
3931 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3933 TRACE("iface %p, parameter %p, index %u.\n", iface
, parameter
, index
);
3935 return d3dx9_base_effect_get_parameter(&compiler
->base_effect
, parameter
, index
);
3938 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler
*iface
,
3939 D3DXHANDLE parameter
, const char *name
)
3941 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3943 TRACE("iface %p, parameter %p, name %s.\n", iface
, parameter
, debugstr_a(name
));
3945 return d3dx9_base_effect_get_parameter_by_name(&compiler
->base_effect
, parameter
, name
);
3948 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler
*iface
,
3949 D3DXHANDLE parameter
, const char *semantic
)
3951 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3953 TRACE("iface %p, parameter %p, semantic %s.\n", iface
, parameter
, debugstr_a(semantic
));
3955 return d3dx9_base_effect_get_parameter_by_semantic(&compiler
->base_effect
, parameter
, semantic
);
3958 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler
*iface
,
3959 D3DXHANDLE parameter
, UINT index
)
3961 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3963 TRACE("iface %p, parameter %p, index %u.\n", iface
, parameter
, index
);
3965 return d3dx9_base_effect_get_parameter_element(&compiler
->base_effect
, parameter
, index
);
3968 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler
*iface
, UINT index
)
3970 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3972 TRACE("iface %p, index %u.\n", iface
, index
);
3974 return d3dx9_base_effect_get_technique(&compiler
->base_effect
, index
);
3977 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler
*iface
, const char *name
)
3979 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3981 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
3983 return d3dx9_base_effect_get_technique_by_name(&compiler
->base_effect
, name
);
3986 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler
*iface
, D3DXHANDLE technique
, UINT index
)
3988 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3990 TRACE("iface %p, technique %p, index %u.\n", iface
, technique
, index
);
3992 return d3dx9_base_effect_get_pass(&compiler
->base_effect
, technique
, index
);
3995 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler
*iface
,
3996 D3DXHANDLE technique
, const char *name
)
3998 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4000 TRACE("iface %p, technique %p, name %s.\n", iface
, technique
, debugstr_a(name
));
4002 return d3dx9_base_effect_get_pass_by_name(&compiler
->base_effect
, technique
, name
);
4005 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler
*iface
, UINT index
)
4007 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4009 TRACE("iface %p, index %u.\n", iface
, index
);
4011 return d3dx9_base_effect_get_function(&compiler
->base_effect
, index
);
4014 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler
*iface
, const char *name
)
4016 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4018 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
4020 return d3dx9_base_effect_get_function_by_name(&compiler
->base_effect
, name
);
4023 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler
*iface
,
4024 D3DXHANDLE object
, UINT index
)
4026 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4028 TRACE("iface %p, object %p, index %u.\n", iface
, object
, index
);
4030 return d3dx9_base_effect_get_annotation(&compiler
->base_effect
, object
, index
);
4033 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler
*iface
,
4034 D3DXHANDLE object
, const char *name
)
4036 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4038 TRACE("iface %p, object %p, name %s.\n", iface
, object
, debugstr_a(name
));
4040 return d3dx9_base_effect_get_annotation_by_name(&compiler
->base_effect
, object
, name
);
4043 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler
*iface
,
4044 D3DXHANDLE parameter
, const void *data
, UINT bytes
)
4046 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4048 TRACE("iface %p, parameter %p, data %p, bytes %u.\n", iface
, parameter
, data
, bytes
);
4050 return d3dx9_base_effect_set_value(&compiler
->base_effect
, parameter
, data
, bytes
);
4053 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler
*iface
,
4054 D3DXHANDLE parameter
, void *data
, UINT bytes
)
4056 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4058 TRACE("iface %p, parameter %p, data %p, bytes %u.\n", iface
, parameter
, data
, bytes
);
4060 return d3dx9_base_effect_get_value(&compiler
->base_effect
, parameter
, data
, bytes
);
4063 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL b
)
4065 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4067 TRACE("iface %p, parameter %p, b %#x.\n", iface
, parameter
, b
);
4069 return d3dx9_base_effect_set_bool(&compiler
->base_effect
, parameter
, b
);
4072 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL
*b
)
4074 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4076 TRACE("iface %p, parameter %p, b %p.\n", iface
, parameter
, b
);
4078 return d3dx9_base_effect_get_bool(&compiler
->base_effect
, parameter
, b
);
4081 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler
*iface
,
4082 D3DXHANDLE parameter
, const BOOL
*b
, UINT count
)
4084 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4086 TRACE("iface %p, parameter %p, b %p, count %u.\n", iface
, parameter
, b
, count
);
4088 return d3dx9_base_effect_set_bool_array(&compiler
->base_effect
, parameter
, b
, count
);
4091 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler
*iface
,
4092 D3DXHANDLE parameter
, BOOL
*b
, UINT count
)
4094 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4096 TRACE("iface %p, parameter %p, b %p, count %u.\n", iface
, parameter
, b
, count
);
4098 return d3dx9_base_effect_get_bool_array(&compiler
->base_effect
, parameter
, b
, count
);
4101 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, INT n
)
4103 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4105 TRACE("iface %p, parameter %p, n %d.\n", iface
, parameter
, n
);
4107 return d3dx9_base_effect_set_int(&compiler
->base_effect
, parameter
, n
);
4110 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, INT
*n
)
4112 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4114 TRACE("iface %p, parameter %p, n %p.\n", iface
, parameter
, n
);
4116 return d3dx9_base_effect_get_int(&compiler
->base_effect
, parameter
, n
);
4119 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler
*iface
,
4120 D3DXHANDLE parameter
, const INT
*n
, UINT count
)
4122 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4124 TRACE("iface %p, parameter %p, n %p, count %u.\n", iface
, parameter
, n
, count
);
4126 return d3dx9_base_effect_set_int_array(&compiler
->base_effect
, parameter
, n
, count
);
4129 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler
*iface
,
4130 D3DXHANDLE parameter
, INT
*n
, UINT count
)
4132 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4134 TRACE("iface %p, parameter %p, n %p, count %u.\n", iface
, parameter
, n
, count
);
4136 return d3dx9_base_effect_get_int_array(&compiler
->base_effect
, parameter
, n
, count
);
4139 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, float f
)
4141 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4143 TRACE("iface %p, parameter %p, f %.8e.\n", iface
, parameter
, f
);
4145 return d3dx9_base_effect_set_float(&compiler
->base_effect
, parameter
, f
);
4148 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, float *f
)
4150 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4152 TRACE("iface %p, parameter %p, f %p.\n", iface
, parameter
, f
);
4154 return d3dx9_base_effect_get_float(&compiler
->base_effect
, parameter
, f
);
4157 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler
*iface
,
4158 D3DXHANDLE parameter
, const float *f
, UINT count
)
4160 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4162 TRACE("iface %p, parameter %p, f %p, count %u.\n", iface
, parameter
, f
, count
);
4164 return d3dx9_base_effect_set_float_array(&compiler
->base_effect
, parameter
, f
, count
);
4167 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler
*iface
,
4168 D3DXHANDLE parameter
, float *f
, UINT count
)
4170 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4172 TRACE("iface %p, parameter %p, f %p, count %u.\n", iface
, parameter
, f
, count
);
4174 return d3dx9_base_effect_get_float_array(&compiler
->base_effect
, parameter
, f
, count
);
4177 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler
*iface
,
4178 D3DXHANDLE parameter
, const D3DXVECTOR4
*vector
)
4180 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4182 TRACE("iface %p, parameter %p, vector %p.\n", iface
, parameter
, vector
);
4184 return d3dx9_base_effect_set_vector(&compiler
->base_effect
, parameter
, vector
);
4187 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler
*iface
,
4188 D3DXHANDLE parameter
, D3DXVECTOR4
*vector
)
4190 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4192 TRACE("iface %p, parameter %p, vector %p.\n", iface
, parameter
, vector
);
4194 return d3dx9_base_effect_get_vector(&compiler
->base_effect
, parameter
, vector
);
4197 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler
*iface
,
4198 D3DXHANDLE parameter
, const D3DXVECTOR4
*vector
, UINT count
)
4200 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4202 TRACE("iface %p, parameter %p, vector %p, count %u.\n", iface
, parameter
, vector
, count
);
4204 return d3dx9_base_effect_set_vector_array(&compiler
->base_effect
, parameter
, vector
, count
);
4207 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler
*iface
,
4208 D3DXHANDLE parameter
, D3DXVECTOR4
*vector
, UINT count
)
4210 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4212 TRACE("iface %p, parameter %p, vector %p, count %u.\n", iface
, parameter
, vector
, count
);
4214 return d3dx9_base_effect_get_vector_array(&compiler
->base_effect
, parameter
, vector
, count
);
4217 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler
*iface
,
4218 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
)
4220 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4222 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
4224 return d3dx9_base_effect_set_matrix(&compiler
->base_effect
, parameter
, matrix
);
4227 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler
*iface
,
4228 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
4230 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4232 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
4234 return d3dx9_base_effect_get_matrix(&compiler
->base_effect
, parameter
, matrix
);
4237 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler
*iface
,
4238 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
, UINT count
)
4240 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4242 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
4244 return d3dx9_base_effect_set_matrix_array(&compiler
->base_effect
, parameter
, matrix
, count
);
4247 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler
*iface
,
4248 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
4250 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4252 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
4254 return d3dx9_base_effect_get_matrix_array(&compiler
->base_effect
, parameter
, matrix
, count
);
4257 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler
*iface
,
4258 D3DXHANDLE parameter
, const D3DXMATRIX
**matrix
, UINT count
)
4260 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4262 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
4264 return d3dx9_base_effect_set_matrix_pointer_array(&compiler
->base_effect
, parameter
, matrix
, count
);
4267 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler
*iface
,
4268 D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
4270 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4272 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
4274 return d3dx9_base_effect_get_matrix_pointer_array(&compiler
->base_effect
, parameter
, matrix
, count
);
4277 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler
*iface
,
4278 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
)
4280 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4282 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
4284 return d3dx9_base_effect_set_matrix_transpose(&compiler
->base_effect
, parameter
, matrix
);
4287 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler
*iface
,
4288 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
4290 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4292 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
4294 return d3dx9_base_effect_get_matrix_transpose(&compiler
->base_effect
, parameter
, matrix
);
4297 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler
*iface
,
4298 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
, UINT count
)
4300 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4302 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
4304 return d3dx9_base_effect_set_matrix_transpose_array(&compiler
->base_effect
, parameter
, matrix
, count
);
4307 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler
*iface
,
4308 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
4310 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4312 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
4314 return d3dx9_base_effect_get_matrix_transpose_array(&compiler
->base_effect
, parameter
, matrix
, count
);
4317 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler
*iface
,
4318 D3DXHANDLE parameter
, const D3DXMATRIX
**matrix
, UINT count
)
4320 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4322 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
4324 return d3dx9_base_effect_set_matrix_transpose_pointer_array(&compiler
->base_effect
, parameter
, matrix
, count
);
4327 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler
*iface
,
4328 D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
4330 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4332 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
4334 return d3dx9_base_effect_get_matrix_transpose_pointer_array(&compiler
->base_effect
, parameter
, matrix
, count
);
4337 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler
*iface
,
4338 D3DXHANDLE parameter
, const char *string
)
4340 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4342 TRACE("iface %p, parameter %p, string %s.\n", iface
, parameter
, debugstr_a(string
));
4344 return d3dx9_base_effect_set_string(&compiler
->base_effect
, parameter
, string
);
4347 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler
*iface
,
4348 D3DXHANDLE parameter
, const char **string
)
4350 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4352 TRACE("iface %p, parameter %p, string %p.\n", iface
, parameter
, string
);
4354 return d3dx9_base_effect_get_string(&compiler
->base_effect
, parameter
, string
);
4357 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetTexture(struct ID3DXEffectCompiler
*iface
,
4358 D3DXHANDLE parameter
, struct IDirect3DBaseTexture9
*texture
)
4360 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4362 TRACE("iface %p, parameter %p, texture %p.\n", iface
, parameter
, texture
);
4364 return d3dx9_base_effect_set_texture(&compiler
->base_effect
, parameter
, texture
);
4367 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetTexture(struct ID3DXEffectCompiler
*iface
,
4368 D3DXHANDLE parameter
, struct IDirect3DBaseTexture9
**texture
)
4370 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4372 TRACE("iface %p, parameter %p, texture %p.\n", iface
, parameter
, texture
);
4374 return d3dx9_base_effect_get_texture(&compiler
->base_effect
, parameter
, texture
);
4377 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler
*iface
,
4378 D3DXHANDLE parameter
, struct IDirect3DPixelShader9
**shader
)
4380 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4382 TRACE("iface %p, parameter %p, shader %p.\n", iface
, parameter
, shader
);
4384 return d3dx9_base_effect_get_pixel_shader(&compiler
->base_effect
, parameter
, shader
);
4387 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetVertexShader(struct ID3DXEffectCompiler
*iface
,
4388 D3DXHANDLE parameter
, struct IDirect3DVertexShader9
**shader
)
4390 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4392 TRACE("iface %p, parameter %p, shader %p.\n", iface
, parameter
, shader
);
4394 return d3dx9_base_effect_get_vertex_shader(&compiler
->base_effect
, parameter
, shader
);
4397 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler
*iface
,
4398 D3DXHANDLE parameter
, UINT start
, UINT end
)
4400 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4402 TRACE("iface %p, parameter %p, start %u, end %u.\n", iface
, parameter
, start
, end
);
4404 return d3dx9_base_effect_set_array_range(&compiler
->base_effect
, parameter
, start
, end
);
4407 /*** ID3DXEffectCompiler methods ***/
4408 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL literal
)
4410 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4412 FIXME("iface %p, parameter %p, literal %u\n", This
, parameter
, literal
);
4417 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL
*literal
)
4419 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4421 FIXME("iface %p, parameter %p, literal %p\n", This
, parameter
, literal
);
4426 static HRESULT WINAPI
ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler
*iface
, DWORD flags
,
4427 ID3DXBuffer
**effect
, ID3DXBuffer
**error_msgs
)
4429 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4431 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This
, flags
, effect
, error_msgs
);
4436 static HRESULT WINAPI
ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler
*iface
, D3DXHANDLE function
,
4437 const char *target
, DWORD flags
, ID3DXBuffer
**shader
, ID3DXBuffer
**error_msgs
,
4438 ID3DXConstantTable
**constant_table
)
4440 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4442 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
4443 This
, function
, target
, flags
, shader
, error_msgs
, constant_table
);
4448 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl
=
4450 /*** IUnknown methods ***/
4451 ID3DXEffectCompilerImpl_QueryInterface
,
4452 ID3DXEffectCompilerImpl_AddRef
,
4453 ID3DXEffectCompilerImpl_Release
,
4454 /*** ID3DXBaseEffect methods ***/
4455 ID3DXEffectCompilerImpl_GetDesc
,
4456 ID3DXEffectCompilerImpl_GetParameterDesc
,
4457 ID3DXEffectCompilerImpl_GetTechniqueDesc
,
4458 ID3DXEffectCompilerImpl_GetPassDesc
,
4459 ID3DXEffectCompilerImpl_GetFunctionDesc
,
4460 ID3DXEffectCompilerImpl_GetParameter
,
4461 ID3DXEffectCompilerImpl_GetParameterByName
,
4462 ID3DXEffectCompilerImpl_GetParameterBySemantic
,
4463 ID3DXEffectCompilerImpl_GetParameterElement
,
4464 ID3DXEffectCompilerImpl_GetTechnique
,
4465 ID3DXEffectCompilerImpl_GetTechniqueByName
,
4466 ID3DXEffectCompilerImpl_GetPass
,
4467 ID3DXEffectCompilerImpl_GetPassByName
,
4468 ID3DXEffectCompilerImpl_GetFunction
,
4469 ID3DXEffectCompilerImpl_GetFunctionByName
,
4470 ID3DXEffectCompilerImpl_GetAnnotation
,
4471 ID3DXEffectCompilerImpl_GetAnnotationByName
,
4472 ID3DXEffectCompilerImpl_SetValue
,
4473 ID3DXEffectCompilerImpl_GetValue
,
4474 ID3DXEffectCompilerImpl_SetBool
,
4475 ID3DXEffectCompilerImpl_GetBool
,
4476 ID3DXEffectCompilerImpl_SetBoolArray
,
4477 ID3DXEffectCompilerImpl_GetBoolArray
,
4478 ID3DXEffectCompilerImpl_SetInt
,
4479 ID3DXEffectCompilerImpl_GetInt
,
4480 ID3DXEffectCompilerImpl_SetIntArray
,
4481 ID3DXEffectCompilerImpl_GetIntArray
,
4482 ID3DXEffectCompilerImpl_SetFloat
,
4483 ID3DXEffectCompilerImpl_GetFloat
,
4484 ID3DXEffectCompilerImpl_SetFloatArray
,
4485 ID3DXEffectCompilerImpl_GetFloatArray
,
4486 ID3DXEffectCompilerImpl_SetVector
,
4487 ID3DXEffectCompilerImpl_GetVector
,
4488 ID3DXEffectCompilerImpl_SetVectorArray
,
4489 ID3DXEffectCompilerImpl_GetVectorArray
,
4490 ID3DXEffectCompilerImpl_SetMatrix
,
4491 ID3DXEffectCompilerImpl_GetMatrix
,
4492 ID3DXEffectCompilerImpl_SetMatrixArray
,
4493 ID3DXEffectCompilerImpl_GetMatrixArray
,
4494 ID3DXEffectCompilerImpl_SetMatrixPointerArray
,
4495 ID3DXEffectCompilerImpl_GetMatrixPointerArray
,
4496 ID3DXEffectCompilerImpl_SetMatrixTranspose
,
4497 ID3DXEffectCompilerImpl_GetMatrixTranspose
,
4498 ID3DXEffectCompilerImpl_SetMatrixTransposeArray
,
4499 ID3DXEffectCompilerImpl_GetMatrixTransposeArray
,
4500 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray
,
4501 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray
,
4502 ID3DXEffectCompilerImpl_SetString
,
4503 ID3DXEffectCompilerImpl_GetString
,
4504 ID3DXEffectCompilerImpl_SetTexture
,
4505 ID3DXEffectCompilerImpl_GetTexture
,
4506 ID3DXEffectCompilerImpl_GetPixelShader
,
4507 ID3DXEffectCompilerImpl_GetVertexShader
,
4508 ID3DXEffectCompilerImpl_SetArrayRange
,
4509 /*** ID3DXEffectCompiler methods ***/
4510 ID3DXEffectCompilerImpl_SetLiteral
,
4511 ID3DXEffectCompilerImpl_GetLiteral
,
4512 ID3DXEffectCompilerImpl_CompileEffect
,
4513 ID3DXEffectCompilerImpl_CompileShader
,
4516 static HRESULT
d3dx9_parse_sampler(struct d3dx9_base_effect
*base
, struct d3dx_sampler
*sampler
,
4517 const char *data
, const char **ptr
, struct d3dx_object
*objects
)
4522 read_dword(ptr
, &sampler
->state_count
);
4523 TRACE("Count: %u\n", sampler
->state_count
);
4525 sampler
->states
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*sampler
->states
) * sampler
->state_count
);
4526 if (!sampler
->states
)
4528 ERR("Out of memory\n");
4529 return E_OUTOFMEMORY
;
4532 for (i
= 0; i
< sampler
->state_count
; ++i
)
4534 hr
= d3dx9_parse_state(base
, &sampler
->states
[i
], data
, ptr
, objects
);
4537 WARN("Failed to parse state %u\n", i
);
4546 for (i
= 0; i
< sampler
->state_count
; ++i
)
4548 free_state(&sampler
->states
[i
]);
4550 HeapFree(GetProcessHeap(), 0, sampler
->states
);
4551 sampler
->states
= NULL
;
4556 static HRESULT
d3dx9_parse_value(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*param
,
4557 void *value
, const char *data
, const char **ptr
, struct d3dx_object
*objects
)
4563 if (param
->element_count
)
4565 param
->data
= value
;
4567 for (i
= 0; i
< param
->element_count
; ++i
)
4569 struct d3dx_parameter
*member
= ¶m
->members
[i
];
4571 hr
= d3dx9_parse_value(base
, member
, value
? (char *)value
+ old_size
: NULL
, data
, ptr
, objects
);
4574 WARN("Failed to parse value %u\n", i
);
4578 old_size
+= member
->bytes
;
4584 switch(param
->class)
4588 case D3DXPC_MATRIX_ROWS
:
4589 case D3DXPC_MATRIX_COLUMNS
:
4590 param
->data
= value
;
4594 param
->data
= value
;
4596 for (i
= 0; i
< param
->member_count
; ++i
)
4598 struct d3dx_parameter
*member
= ¶m
->members
[i
];
4600 hr
= d3dx9_parse_value(base
, member
, (char *)value
+ old_size
, data
, ptr
, objects
);
4603 WARN("Failed to parse value %u\n", i
);
4607 old_size
+= member
->bytes
;
4612 switch (param
->type
)
4615 case D3DXPT_TEXTURE
:
4616 case D3DXPT_TEXTURE1D
:
4617 case D3DXPT_TEXTURE2D
:
4618 case D3DXPT_TEXTURE3D
:
4619 case D3DXPT_TEXTURECUBE
:
4620 case D3DXPT_PIXELSHADER
:
4621 case D3DXPT_VERTEXSHADER
:
4622 read_dword(ptr
, ¶m
->object_id
);
4623 TRACE("Id: %u\n", param
->object_id
);
4624 objects
[param
->object_id
].param
= param
;
4625 param
->data
= value
;
4628 case D3DXPT_SAMPLER
:
4629 case D3DXPT_SAMPLER1D
:
4630 case D3DXPT_SAMPLER2D
:
4631 case D3DXPT_SAMPLER3D
:
4632 case D3DXPT_SAMPLERCUBE
:
4634 struct d3dx_sampler
*sampler
;
4636 sampler
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*sampler
));
4638 return E_OUTOFMEMORY
;
4640 hr
= d3dx9_parse_sampler(base
, sampler
, data
, ptr
, objects
);
4643 HeapFree(GetProcessHeap(), 0, sampler
);
4644 WARN("Failed to parse sampler\n");
4648 param
->data
= sampler
;
4653 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
4659 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
4666 static HRESULT
d3dx9_parse_init_value(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*param
,
4667 const char *data
, const char *ptr
, struct d3dx_object
*objects
)
4669 UINT size
= param
->bytes
;
4673 TRACE("param size: %u\n", size
);
4677 value
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
4680 ERR("Failed to allocate data memory.\n");
4681 return E_OUTOFMEMORY
;
4684 switch(param
->class)
4691 case D3DXPC_MATRIX_ROWS
:
4692 case D3DXPC_MATRIX_COLUMNS
:
4694 TRACE("Data: %s.\n", debugstr_an(ptr
, size
));
4695 memcpy(value
, ptr
, size
);
4699 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
4704 hr
= d3dx9_parse_value(base
, param
, value
, data
, &ptr
, objects
);
4707 WARN("Failed to parse value\n");
4708 HeapFree(GetProcessHeap(), 0, value
);
4715 static HRESULT
d3dx9_parse_name(char **name
, const char *ptr
)
4719 read_dword(&ptr
, &size
);
4720 TRACE("Name size: %#x\n", size
);
4727 *name
= HeapAlloc(GetProcessHeap(), 0, size
);
4730 ERR("Failed to allocate name memory.\n");
4731 return E_OUTOFMEMORY
;
4734 TRACE("Name: %s.\n", debugstr_an(ptr
, size
));
4735 memcpy(*name
, ptr
, size
);
4740 static HRESULT
d3dx9_copy_data(struct d3dx_object
*object
, const char **ptr
)
4742 if (object
->size
|| object
->data
)
4743 FIXME("Object already initialized!\n");
4745 read_dword(ptr
, &object
->size
);
4746 TRACE("Data size: %#x\n", object
->size
);
4751 object
->data
= HeapAlloc(GetProcessHeap(), 0, object
->size
);
4754 ERR("Failed to allocate object memory.\n");
4755 return E_OUTOFMEMORY
;
4758 TRACE("Data: %s.\n", debugstr_an(*ptr
, object
->size
));
4759 memcpy(object
->data
, *ptr
, object
->size
);
4761 *ptr
+= ((object
->size
+ 3) & ~3);
4766 static void add_param_to_table(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*param
)
4768 struct param_table
*table
= &base
->param_table
;
4770 if (table
->count
>= table
->size
)
4772 unsigned int new_size
;
4773 struct d3dx_parameter
**new_alloc
;
4777 new_size
= INITIAL_PARAM_TABLE_SIZE
;
4778 new_alloc
= HeapAlloc(GetProcessHeap(), 0, sizeof(*table
->table
) * new_size
);
4781 ERR("Out of memory.\n");
4787 new_size
= table
->size
* 2;
4788 new_alloc
= HeapReAlloc(GetProcessHeap(), 0, table
->table
, sizeof(*table
->table
) * new_size
);
4791 ERR("Out of memory.\n");
4795 table
->table
= new_alloc
;
4796 table
->size
= new_size
;
4799 table
->table
[table
->count
++] = param
;
4802 static void sync_param_handles(struct d3dx9_base_effect
*base
)
4804 struct param_table
*table
= &base
->param_table
;
4805 struct d3dx_parameter
**new_alloc
;
4810 new_alloc
= HeapReAlloc(GetProcessHeap(), 0, table
->table
, sizeof(*table
->table
) * table
->count
);
4812 table
->table
= new_alloc
;
4814 ERR("Out of memory.\n");
4817 for (i
= 0; i
< table
->count
; ++i
)
4818 table
->table
[i
]->handle
= (D3DXHANDLE
)&table
->table
[i
];
4821 static HRESULT
d3dx9_parse_effect_typedef(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*param
,
4822 const char *data
, const char **ptr
, struct d3dx_parameter
*parent
, UINT flags
)
4828 param
->flags
= flags
;
4832 read_dword(ptr
, (DWORD
*)¶m
->type
);
4833 TRACE("Type: %s\n", debug_d3dxparameter_type(param
->type
));
4835 read_dword(ptr
, (DWORD
*)¶m
->class);
4836 TRACE("Class: %s\n", debug_d3dxparameter_class(param
->class));
4838 read_dword(ptr
, &offset
);
4839 TRACE("Type name offset: %#x\n", offset
);
4840 hr
= d3dx9_parse_name(¶m
->name
, data
+ offset
);
4843 WARN("Failed to parse name\n");
4847 read_dword(ptr
, &offset
);
4848 TRACE("Type semantic offset: %#x\n", offset
);
4849 hr
= d3dx9_parse_name(¶m
->semantic
, data
+ offset
);
4852 WARN("Failed to parse semantic\n");
4856 read_dword(ptr
, ¶m
->element_count
);
4857 TRACE("Elements: %u\n", param
->element_count
);
4859 switch (param
->class)
4862 read_dword(ptr
, ¶m
->columns
);
4863 TRACE("Columns: %u\n", param
->columns
);
4865 read_dword(ptr
, ¶m
->rows
);
4866 TRACE("Rows: %u\n", param
->rows
);
4868 /* sizeof(DWORD) * rows * columns */
4869 param
->bytes
= 4 * param
->rows
* param
->columns
;
4873 case D3DXPC_MATRIX_ROWS
:
4874 case D3DXPC_MATRIX_COLUMNS
:
4875 read_dword(ptr
, ¶m
->rows
);
4876 TRACE("Rows: %u\n", param
->rows
);
4878 read_dword(ptr
, ¶m
->columns
);
4879 TRACE("Columns: %u\n", param
->columns
);
4881 /* sizeof(DWORD) * rows * columns */
4882 param
->bytes
= 4 * param
->rows
* param
->columns
;
4886 read_dword(ptr
, ¶m
->member_count
);
4887 TRACE("Members: %u\n", param
->member_count
);
4891 switch (param
->type
)
4894 case D3DXPT_PIXELSHADER
:
4895 case D3DXPT_VERTEXSHADER
:
4896 case D3DXPT_TEXTURE
:
4897 case D3DXPT_TEXTURE1D
:
4898 case D3DXPT_TEXTURE2D
:
4899 case D3DXPT_TEXTURE3D
:
4900 case D3DXPT_TEXTURECUBE
:
4901 param
->bytes
= sizeof(void *);
4904 case D3DXPT_SAMPLER
:
4905 case D3DXPT_SAMPLER1D
:
4906 case D3DXPT_SAMPLER2D
:
4907 case D3DXPT_SAMPLER3D
:
4908 case D3DXPT_SAMPLERCUBE
:
4913 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
4919 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
4926 param
->type
= parent
->type
;
4927 param
->class = parent
->class;
4928 param
->name
= parent
->name
;
4929 param
->semantic
= parent
->semantic
;
4930 param
->element_count
= 0;
4931 param
->annotation_count
= 0;
4932 param
->member_count
= parent
->member_count
;
4933 param
->bytes
= parent
->bytes
;
4934 param
->rows
= parent
->rows
;
4935 param
->columns
= parent
->columns
;
4938 if (param
->element_count
)
4940 unsigned int param_bytes
= 0;
4941 const char *save_ptr
= *ptr
;
4943 param
->members
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*param
->members
) * param
->element_count
);
4944 if (!param
->members
)
4946 ERR("Out of memory\n");
4951 for (i
= 0; i
< param
->element_count
; ++i
)
4955 add_param_to_table(base
, ¶m
->members
[i
]);
4956 hr
= d3dx9_parse_effect_typedef(base
, ¶m
->members
[i
], data
, ptr
, param
, flags
);
4959 WARN("Failed to parse member %u\n", i
);
4963 param_bytes
+= param
->members
[i
].bytes
;
4966 param
->bytes
= param_bytes
;
4968 else if (param
->member_count
)
4970 param
->members
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*param
->members
) * param
->member_count
);
4971 if (!param
->members
)
4973 ERR("Out of memory\n");
4978 for (i
= 0; i
< param
->member_count
; ++i
)
4980 add_param_to_table(base
, ¶m
->members
[i
]);
4981 hr
= d3dx9_parse_effect_typedef(base
, ¶m
->members
[i
], data
, ptr
, NULL
, flags
);
4984 WARN("Failed to parse member %u\n", i
);
4988 param
->bytes
+= param
->members
[i
].bytes
;
4997 unsigned int count
= param
->element_count
? param
->element_count
: param
->member_count
;
4999 for (i
= 0; i
< count
; ++i
)
5000 free_parameter(¶m
->members
[i
], param
->element_count
!= 0, TRUE
);
5001 HeapFree(GetProcessHeap(), 0, param
->members
);
5002 param
->members
= NULL
;
5007 HeapFree(GetProcessHeap(), 0, param
->name
);
5008 HeapFree(GetProcessHeap(), 0, param
->semantic
);
5011 param
->semantic
= NULL
;
5016 static HRESULT
d3dx9_parse_effect_annotation(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*anno
,
5017 const char *data
, const char **ptr
, struct d3dx_object
*objects
)
5023 anno
->flags
= D3DX_PARAMETER_ANNOTATION
;
5025 read_dword(ptr
, &offset
);
5026 TRACE("Typedef offset: %#x\n", offset
);
5027 ptr2
= data
+ offset
;
5028 hr
= d3dx9_parse_effect_typedef(base
, anno
, data
, &ptr2
, NULL
, D3DX_PARAMETER_ANNOTATION
);
5031 WARN("Failed to parse type definition\n");
5035 read_dword(ptr
, &offset
);
5036 TRACE("Value offset: %#x\n", offset
);
5037 hr
= d3dx9_parse_init_value(base
, anno
, data
, data
+ offset
, objects
);
5040 WARN("Failed to parse value\n");
5047 static HRESULT
d3dx9_parse_state(struct d3dx9_base_effect
*base
, struct d3dx_state
*state
,
5048 const char *data
, const char **ptr
, struct d3dx_object
*objects
)
5054 state
->type
= ST_CONSTANT
;
5056 read_dword(ptr
, &state
->operation
);
5057 TRACE("Operation: %#x (%s)\n", state
->operation
, state_table
[state
->operation
].name
);
5059 read_dword(ptr
, &state
->index
);
5060 TRACE("Index: %#x\n", state
->index
);
5062 read_dword(ptr
, &offset
);
5063 TRACE("Typedef offset: %#x\n", offset
);
5064 ptr2
= data
+ offset
;
5065 hr
= d3dx9_parse_effect_typedef(base
, &state
->parameter
, data
, &ptr2
, NULL
, 0);
5068 WARN("Failed to parse type definition\n");
5072 read_dword(ptr
, &offset
);
5073 TRACE("Value offset: %#x\n", offset
);
5074 hr
= d3dx9_parse_init_value(base
, &state
->parameter
, data
, data
+ offset
, objects
);
5077 WARN("Failed to parse value\n");
5085 free_parameter(&state
->parameter
, FALSE
, FALSE
);
5090 static HRESULT
d3dx9_parse_effect_parameter(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*param
,
5091 const char *data
, const char **ptr
, struct d3dx_object
*objects
)
5098 read_dword(ptr
, &offset
);
5099 TRACE("Typedef offset: %#x\n", offset
);
5100 ptr2
= data
+ offset
;
5102 read_dword(ptr
, &offset
);
5103 TRACE("Value offset: %#x\n", offset
);
5105 read_dword(ptr
, ¶m
->flags
);
5106 TRACE("Flags: %#x\n", param
->flags
);
5108 read_dword(ptr
, ¶m
->annotation_count
);
5109 TRACE("Annotation count: %u\n", param
->annotation_count
);
5111 hr
= d3dx9_parse_effect_typedef(base
, param
, data
, &ptr2
, NULL
, param
->flags
);
5114 WARN("Failed to parse type definition\n");
5118 hr
= d3dx9_parse_init_value(base
, param
, data
, data
+ offset
, objects
);
5121 WARN("Failed to parse value\n");
5125 if (param
->annotation_count
)
5127 param
->annotations
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
5128 sizeof(*param
->annotations
) * param
->annotation_count
);
5129 if (!param
->annotations
)
5131 ERR("Out of memory\n");
5136 for (i
= 0; i
< param
->annotation_count
; ++i
)
5138 add_param_to_table(base
, ¶m
->annotations
[i
]);
5139 hr
= d3dx9_parse_effect_annotation(base
, ¶m
->annotations
[i
], data
, ptr
, objects
);
5142 WARN("Failed to parse annotation\n");
5152 if (param
->annotations
)
5154 for (i
= 0; i
< param
->annotation_count
; ++i
)
5155 free_parameter(¶m
->annotations
[i
], FALSE
, FALSE
);
5156 HeapFree(GetProcessHeap(), 0, param
->annotations
);
5157 param
->annotations
= NULL
;
5163 static HRESULT
d3dx9_parse_effect_pass(struct d3dx9_base_effect
*base
, struct d3dx_pass
*pass
,
5164 const char *data
, const char **ptr
, struct d3dx_object
*objects
)
5169 struct d3dx_state
*states
= NULL
;
5172 read_dword(ptr
, &offset
);
5173 TRACE("Pass name offset: %#x\n", offset
);
5174 hr
= d3dx9_parse_name(&name
, data
+ offset
);
5177 WARN("Failed to parse name\n");
5181 read_dword(ptr
, &pass
->annotation_count
);
5182 TRACE("Annotation count: %u\n", pass
->annotation_count
);
5184 read_dword(ptr
, &pass
->state_count
);
5185 TRACE("State count: %u\n", pass
->state_count
);
5187 if (pass
->annotation_count
)
5189 pass
->annotations
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
5190 sizeof(*pass
->annotations
) * pass
->annotation_count
);
5191 if (!pass
->annotations
)
5193 ERR("Out of memory\n");
5198 for (i
= 0; i
< pass
->annotation_count
; ++i
)
5200 add_param_to_table(base
, &pass
->annotations
[i
]);
5201 hr
= d3dx9_parse_effect_annotation(base
, &pass
->annotations
[i
], data
, ptr
, objects
);
5204 WARN("Failed to parse annotation %u\n", i
);
5210 if (pass
->state_count
)
5212 states
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*states
) * pass
->state_count
);
5215 ERR("Out of memory\n");
5220 for (i
= 0; i
< pass
->state_count
; ++i
)
5222 hr
= d3dx9_parse_state(base
, &states
[i
], data
, ptr
, objects
);
5225 WARN("Failed to parse annotation %u\n", i
);
5232 pass
->states
= states
;
5238 if (pass
->annotations
)
5240 for (i
= 0; i
< pass
->annotation_count
; ++i
)
5241 free_parameter(&pass
->annotations
[i
], FALSE
, FALSE
);
5242 HeapFree(GetProcessHeap(), 0, pass
->annotations
);
5243 pass
->annotations
= NULL
;
5248 for (i
= 0; i
< pass
->state_count
; ++i
)
5250 free_state(&states
[i
]);
5252 HeapFree(GetProcessHeap(), 0, states
);
5255 HeapFree(GetProcessHeap(), 0, name
);
5260 static HRESULT
d3dx9_parse_effect_technique(struct d3dx9_base_effect
*base
, struct d3dx_technique
*technique
,
5261 const char *data
, const char **ptr
, struct d3dx_object
*objects
)
5268 read_dword(ptr
, &offset
);
5269 TRACE("Technique name offset: %#x\n", offset
);
5270 hr
= d3dx9_parse_name(&name
, data
+ offset
);
5273 WARN("Failed to parse name\n");
5277 read_dword(ptr
, &technique
->annotation_count
);
5278 TRACE("Annotation count: %u\n", technique
->annotation_count
);
5280 read_dword(ptr
, &technique
->pass_count
);
5281 TRACE("Pass count: %u\n", technique
->pass_count
);
5283 if (technique
->annotation_count
)
5285 technique
->annotations
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
5286 sizeof(*technique
->annotations
) * technique
->annotation_count
);
5287 if (!technique
->annotations
)
5289 ERR("Out of memory\n");
5294 for (i
= 0; i
< technique
->annotation_count
; ++i
)
5296 add_param_to_table(base
, &technique
->annotations
[i
]);
5297 hr
= d3dx9_parse_effect_annotation(base
, &technique
->annotations
[i
], data
, ptr
, objects
);
5300 WARN("Failed to parse annotation %u\n", i
);
5306 if (technique
->pass_count
)
5308 technique
->passes
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
5309 sizeof(*technique
->passes
) * technique
->pass_count
);
5310 if (!technique
->passes
)
5312 ERR("Out of memory\n");
5317 for (i
= 0; i
< technique
->pass_count
; ++i
)
5319 hr
= d3dx9_parse_effect_pass(base
, &technique
->passes
[i
], data
, ptr
, objects
);
5322 WARN("Failed to parse pass %u\n", i
);
5328 technique
->name
= name
;
5334 if (technique
->passes
)
5336 for (i
= 0; i
< technique
->pass_count
; ++i
)
5337 free_pass(&technique
->passes
[i
]);
5338 HeapFree(GetProcessHeap(), 0, technique
->passes
);
5339 technique
->passes
= NULL
;
5342 if (technique
->annotations
)
5344 for (i
= 0; i
< technique
->annotation_count
; ++i
)
5345 free_parameter(&technique
->annotations
[i
], FALSE
, FALSE
);
5346 HeapFree(GetProcessHeap(), 0, technique
->annotations
);
5347 technique
->annotations
= NULL
;
5350 HeapFree(GetProcessHeap(), 0, name
);
5355 static HRESULT
d3dx9_create_object(struct d3dx9_base_effect
*base
, struct d3dx_object
*object
)
5357 struct d3dx_parameter
*param
= object
->param
;
5358 struct IDirect3DDevice9
*device
= base
->effect
->device
;
5361 if (*(char **)param
->data
)
5362 ERR("Parameter data already allocated.\n");
5364 switch (param
->type
)
5367 *(char **)param
->data
= HeapAlloc(GetProcessHeap(), 0, object
->size
);
5368 if (!*(char **)param
->data
)
5370 ERR("Out of memory.\n");
5371 return E_OUTOFMEMORY
;
5373 memcpy(*(char **)param
->data
, object
->data
, object
->size
);
5375 case D3DXPT_VERTEXSHADER
:
5376 if (FAILED(hr
= IDirect3DDevice9_CreateVertexShader(device
, object
->data
,
5377 (IDirect3DVertexShader9
**)param
->data
)))
5379 WARN("Failed to create vertex shader.\n");
5383 case D3DXPT_PIXELSHADER
:
5384 if (FAILED(hr
= IDirect3DDevice9_CreatePixelShader(device
, object
->data
,
5385 (IDirect3DPixelShader9
**)param
->data
)))
5387 WARN("Failed to create pixel shader.\n");
5397 static HRESULT
d3dx9_parse_array_selector(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*param
)
5400 struct d3dx_object
*object
= &base
->objects
[param
->object_id
];
5401 char *ptr
= object
->data
;
5404 TRACE("Parsing array entry selection state for parameter %p.\n", param
);
5406 string_size
= *(DWORD
*)ptr
;
5407 param
->referenced_param
= get_parameter_by_name(base
, NULL
, ptr
+ 4);
5408 if (param
->referenced_param
)
5410 TRACE("Mapping to parameter %s.\n", debugstr_a(param
->referenced_param
->name
));
5414 FIXME("Referenced parameter %s not found.\n", ptr
+ 4);
5415 return D3DXERR_INVALIDDATA
;
5417 TRACE("Unknown DWORD: 0x%.8x.\n", *(DWORD
*)(ptr
+ string_size
));
5419 if (string_size
% sizeof(DWORD
))
5420 FIXME("Unaligned string_size %u.\n", string_size
);
5421 d3dx_create_param_eval(base
, (DWORD
*)(ptr
+ string_size
) + 1, object
->size
- (string_size
+ sizeof(DWORD
)),
5422 D3DXPT_INT
, ¶m
->param_eval
);
5424 param
= param
->referenced_param
;
5425 if (param
->type
== D3DXPT_VERTEXSHADER
|| param
->type
== D3DXPT_PIXELSHADER
)
5429 for (i
= 0; i
< param
->element_count
; i
++)
5431 if (param
->members
[i
].type
!= param
->type
)
5433 FIXME("Unexpected member parameter type %u, expected %u.\n", param
->members
[i
].type
, param
->type
);
5434 return D3DXERR_INVALIDDATA
;
5436 if (!param
->members
[i
].param_eval
)
5438 TRACE("Creating preshader for object %u.\n", param
->members
[i
].object_id
);
5439 object
= &base
->objects
[param
->members
[i
].object_id
];
5440 d3dx_create_param_eval(base
, object
->data
, object
->size
, param
->type
, ¶m
->members
[i
].param_eval
);
5447 static HRESULT
d3dx9_parse_resource(struct d3dx9_base_effect
*base
, const char *data
, const char **ptr
)
5449 DWORD technique_index
;
5450 DWORD index
, state_index
, usage
, element_index
;
5451 struct d3dx_state
*state
;
5452 struct d3dx_parameter
*param
;
5453 struct d3dx_object
*object
;
5454 HRESULT hr
= E_FAIL
;
5456 read_dword(ptr
, &technique_index
);
5457 TRACE("technique_index: %u\n", technique_index
);
5459 read_dword(ptr
, &index
);
5460 TRACE("index: %u\n", index
);
5462 read_dword(ptr
, &element_index
);
5463 TRACE("element_index: %u\n", element_index
);
5465 read_dword(ptr
, &state_index
);
5466 TRACE("state_index: %u\n", state_index
);
5468 read_dword(ptr
, &usage
);
5469 TRACE("usage: %u\n", usage
);
5471 if (technique_index
== 0xffffffff)
5473 struct d3dx_parameter
*parameter
;
5474 struct d3dx_sampler
*sampler
;
5476 if (index
>= base
->parameter_count
)
5478 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index
, base
->parameter_count
);
5482 parameter
= &base
->parameters
[index
];
5483 if (element_index
!= 0xffffffff)
5485 if (element_index
>= parameter
->element_count
&& parameter
->element_count
!= 0)
5487 FIXME("Index out of bounds: element_index %u >= element_count %u\n", element_index
, parameter
->element_count
);
5491 if (parameter
->element_count
!= 0) parameter
= ¶meter
->members
[element_index
];
5494 sampler
= parameter
->data
;
5495 if (state_index
>= sampler
->state_count
)
5497 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index
, sampler
->state_count
);
5501 state
= &sampler
->states
[state_index
];
5505 struct d3dx_technique
*technique
;
5506 struct d3dx_pass
*pass
;
5508 if (technique_index
>= base
->technique_count
)
5510 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index
, base
->technique_count
);
5514 technique
= &base
->techniques
[technique_index
];
5515 if (index
>= technique
->pass_count
)
5517 FIXME("Index out of bounds: index %u >= pass_count %u\n", index
, technique
->pass_count
);
5521 pass
= &technique
->passes
[index
];
5522 if (state_index
>= pass
->state_count
)
5524 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index
, pass
->state_count
);
5528 state
= &pass
->states
[state_index
];
5531 TRACE("State operation %#x (%s).\n", state
->operation
, state_table
[state
->operation
].name
);
5532 param
= &state
->parameter
;
5533 TRACE("Using object id %u.\n", param
->object_id
);
5534 object
= &base
->objects
[param
->object_id
];
5536 TRACE("Usage %u: class %s, type %s.\n", usage
, debug_d3dxparameter_class(param
->class),
5537 debug_d3dxparameter_type(param
->type
));
5541 switch (param
->type
)
5543 case D3DXPT_VERTEXSHADER
:
5544 case D3DXPT_PIXELSHADER
:
5545 state
->type
= ST_CONSTANT
;
5546 if (FAILED(hr
= d3dx9_copy_data(&base
->objects
[param
->object_id
], ptr
)))
5551 if (FAILED(hr
= d3dx9_create_object(base
, object
)))
5553 d3dx_create_param_eval(base
, object
->data
, object
->size
, param
->type
, ¶m
->param_eval
);
5561 state
->type
= ST_FXLC
;
5562 if (FAILED(hr
= d3dx9_copy_data(&base
->objects
[param
->object_id
], ptr
)))
5564 d3dx_create_param_eval(base
, object
->data
, object
->size
, param
->type
, ¶m
->param_eval
);
5568 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
5574 state
->type
= ST_PARAMETER
;
5575 if (FAILED(hr
= d3dx9_copy_data(&base
->objects
[param
->object_id
], ptr
)))
5578 TRACE("Looking for parameter %s.\n", debugstr_a(object
->data
));
5579 param
->referenced_param
= get_parameter_by_name(base
, NULL
, object
->data
);
5580 if (param
->referenced_param
)
5582 struct d3dx_parameter
*refpar
= param
->referenced_param
;
5584 TRACE("Mapping to parameter %p, having object id %u.\n", refpar
, refpar
->object_id
);
5585 if (refpar
->type
== D3DXPT_VERTEXSHADER
|| refpar
->type
== D3DXPT_PIXELSHADER
)
5587 struct d3dx_object
*refobj
= &base
->objects
[refpar
->object_id
];
5589 if (!refpar
->param_eval
)
5590 d3dx_create_param_eval(base
, refobj
->data
, refobj
->size
,
5591 refpar
->type
, &refpar
->param_eval
);
5596 FIXME("Referenced parameter %s not found.\n", (char *)object
->data
);
5597 return D3DXERR_INVALIDDATA
;
5602 state
->type
= ST_ARRAY_SELECTOR
;
5603 if (FAILED(hr
= d3dx9_copy_data(object
, ptr
)))
5605 hr
= d3dx9_parse_array_selector(base
, param
);
5609 FIXME("Unknown usage %x\n", usage
);
5616 static HRESULT
d3dx9_parse_effect(struct d3dx9_base_effect
*base
, const char *data
, UINT data_size
, DWORD start
)
5618 const char *ptr
= data
+ start
;
5619 UINT stringcount
, resourcecount
;
5623 read_dword(&ptr
, &base
->parameter_count
);
5624 TRACE("Parameter count: %u\n", base
->parameter_count
);
5626 read_dword(&ptr
, &base
->technique_count
);
5627 TRACE("Technique count: %u\n", base
->technique_count
);
5629 skip_dword_unknown(&ptr
, 1);
5631 read_dword(&ptr
, &base
->object_count
);
5632 TRACE("Object count: %u\n", base
->object_count
);
5634 base
->objects
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*base
->objects
) * base
->object_count
);
5637 ERR("Out of memory\n");
5642 if (base
->parameter_count
)
5644 base
->parameters
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
5645 sizeof(*base
->parameters
) * base
->parameter_count
);
5646 if (!base
->parameters
)
5648 ERR("Out of memory\n");
5653 for (i
= 0; i
< base
->parameter_count
; ++i
)
5655 add_param_to_table(base
, &base
->parameters
[i
]);
5656 hr
= d3dx9_parse_effect_parameter(base
, &base
->parameters
[i
], data
, &ptr
, base
->objects
);
5659 WARN("Failed to parse parameter %u\n", i
);
5665 if (base
->technique_count
)
5667 base
->techniques
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
5668 sizeof(*base
->techniques
) * base
->technique_count
);
5669 if (!base
->techniques
)
5671 ERR("Out of memory\n");
5676 for (i
= 0; i
< base
->technique_count
; ++i
)
5678 TRACE("Parsing technique %u.\n", i
);
5679 hr
= d3dx9_parse_effect_technique(base
, &base
->techniques
[i
], data
, &ptr
, base
->objects
);
5682 WARN("Failed to parse technique %u\n", i
);
5688 sync_param_handles(base
);
5690 read_dword(&ptr
, &stringcount
);
5691 TRACE("String count: %u\n", stringcount
);
5693 read_dword(&ptr
, &resourcecount
);
5694 TRACE("Resource count: %u\n", resourcecount
);
5696 for (i
= 0; i
< stringcount
; ++i
)
5700 read_dword(&ptr
, &id
);
5701 TRACE("Id: %u\n", id
);
5703 if (FAILED(hr
= d3dx9_copy_data(&base
->objects
[id
], &ptr
)))
5706 if (base
->objects
[id
].data
)
5708 if (FAILED(hr
= d3dx9_create_object(base
, &base
->objects
[id
])))
5713 for (i
= 0; i
< resourcecount
; ++i
)
5715 TRACE("parse resource %u\n", i
);
5717 hr
= d3dx9_parse_resource(base
, data
, &ptr
);
5720 WARN("Failed to parse resource %u\n", i
);
5729 if (base
->techniques
)
5731 for (i
= 0; i
< base
->technique_count
; ++i
)
5732 free_technique(&base
->techniques
[i
]);
5733 HeapFree(GetProcessHeap(), 0, base
->techniques
);
5734 base
->techniques
= NULL
;
5737 if (base
->parameters
)
5739 for (i
= 0; i
< base
->parameter_count
; ++i
)
5741 free_parameter(&base
->parameters
[i
], FALSE
, FALSE
);
5743 HeapFree(GetProcessHeap(), 0, base
->parameters
);
5744 base
->parameters
= NULL
;
5749 for (i
= 0; i
< base
->object_count
; ++i
)
5751 free_object(&base
->objects
[i
]);
5753 HeapFree(GetProcessHeap(), 0, base
->objects
);
5754 base
->objects
= NULL
;
5760 static HRESULT
d3dx9_base_effect_init(struct d3dx9_base_effect
*base
,
5761 const char *data
, SIZE_T data_size
, const D3D_SHADER_MACRO
*defines
, ID3DInclude
*include
,
5762 UINT eflags
, ID3DBlob
**errors
, struct ID3DXEffectImpl
*effect
)
5765 const char *ptr
= data
;
5767 ID3DBlob
*bytecode
= NULL
, *temp_errors
= NULL
;
5769 TRACE("base %p, data %p, data_size %lu, effect %p\n", base
, data
, data_size
, effect
);
5771 base
->effect
= effect
;
5773 read_dword(&ptr
, &tag
);
5774 TRACE("Tag: %x\n", tag
);
5776 if (tag
!= d3dx9_effect_version(9, 1))
5778 TRACE("HLSL ASCII effect, trying to compile it.\n");
5779 hr
= D3DCompile(data
, data_size
, NULL
, defines
, include
,
5780 "main", "fx_2_0", 0, eflags
, &bytecode
, &temp_errors
);
5783 WARN("Failed to compile ASCII effect.\n");
5785 ID3D10Blob_Release(bytecode
);
5787 TRACE("%s\n", (char *)ID3D10Blob_GetBufferPointer(temp_errors
));
5789 *errors
= temp_errors
;
5790 else if (temp_errors
)
5791 ID3D10Blob_Release(temp_errors
);
5796 FIXME("No output from effect compilation.\n");
5797 return D3DERR_INVALIDCALL
;
5800 *errors
= temp_errors
;
5801 else if (temp_errors
)
5802 ID3D10Blob_Release(temp_errors
);
5804 ptr
= ID3D10Blob_GetBufferPointer(bytecode
);
5805 read_dword(&ptr
, &tag
);
5806 TRACE("Tag: %x\n", tag
);
5809 read_dword(&ptr
, &offset
);
5810 TRACE("Offset: %x\n", offset
);
5812 hr
= d3dx9_parse_effect(base
, ptr
, data_size
, offset
);
5814 ID3D10Blob_Release(bytecode
);
5817 FIXME("Failed to parse effect.\n");
5824 static HRESULT
d3dx9_effect_init(struct ID3DXEffectImpl
*effect
, struct IDirect3DDevice9
*device
,
5825 const char *data
, SIZE_T data_size
, const D3D_SHADER_MACRO
*defines
, ID3DInclude
*include
,
5826 UINT eflags
, ID3DBlob
**error_messages
, struct ID3DXEffectPool
*pool
)
5830 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect
, device
, data
, data_size
, pool
);
5832 effect
->ID3DXEffect_iface
.lpVtbl
= &ID3DXEffect_Vtbl
;
5835 if (pool
) pool
->lpVtbl
->AddRef(pool
);
5836 effect
->pool
= pool
;
5838 IDirect3DDevice9_AddRef(device
);
5839 effect
->device
= device
;
5841 if (FAILED(hr
= d3dx9_base_effect_init(&effect
->base_effect
, data
, data_size
, defines
, include
,
5842 eflags
, error_messages
, effect
)))
5844 FIXME("Failed to parse effect, hr %#x.\n", hr
);
5845 free_effect(effect
);
5849 /* initialize defaults - check because of unsupported ascii effects */
5850 if (effect
->base_effect
.techniques
)
5852 effect
->active_technique
= &effect
->base_effect
.techniques
[0];
5853 effect
->active_pass
= NULL
;
5859 HRESULT WINAPI
D3DXCreateEffectEx(struct IDirect3DDevice9
*device
, const void *srcdata
, UINT srcdatalen
,
5860 const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, const char *skip_constants
, DWORD flags
,
5861 struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilation_errors
)
5863 struct ID3DXEffectImpl
*object
;
5866 TRACE("device %p, srcdata %p, srcdatalen %u, defines %p, include %p,"
5867 " skip_constants %p, flags %#x, pool %p, effect %p, compilation_errors %p.\n",
5868 device
, srcdata
, srcdatalen
, defines
, include
,
5869 skip_constants
, flags
, pool
, effect
, compilation_errors
);
5871 if (compilation_errors
)
5872 *compilation_errors
= NULL
;
5874 if (!device
|| !srcdata
)
5875 return D3DERR_INVALIDCALL
;
5880 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5885 FIXME("skip_constants is not NULL, not supported yet.\n");
5887 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
5889 return E_OUTOFMEMORY
;
5891 hr
= d3dx9_effect_init(object
, device
, srcdata
, srcdatalen
, (const D3D_SHADER_MACRO
*)defines
,
5892 (ID3DInclude
*)include
, flags
, (ID3DBlob
**)compilation_errors
, pool
);
5895 WARN("Failed to create effect object.\n");
5896 HeapFree(GetProcessHeap(), 0, object
);
5900 *effect
= &object
->ID3DXEffect_iface
;
5902 TRACE("Created ID3DXEffect %p\n", object
);
5907 HRESULT WINAPI
D3DXCreateEffect(struct IDirect3DDevice9
*device
, const void *srcdata
, UINT srcdatalen
,
5908 const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, DWORD flags
,
5909 struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilation_errors
)
5911 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device
, srcdata
, srcdatalen
, defines
,
5912 include
, flags
, pool
, effect
, compilation_errors
);
5914 return D3DXCreateEffectEx(device
, srcdata
, srcdatalen
, defines
, include
, NULL
, flags
, pool
, effect
, compilation_errors
);
5917 static HRESULT
d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl
*compiler
,
5918 const char *data
, SIZE_T data_size
, const D3D_SHADER_MACRO
*defines
, ID3DInclude
*include
,
5919 UINT eflags
, ID3DBlob
**error_messages
)
5923 TRACE("effect %p, data %p, data_size %lu\n", compiler
, data
, data_size
);
5925 compiler
->ID3DXEffectCompiler_iface
.lpVtbl
= &ID3DXEffectCompiler_Vtbl
;
5928 if (FAILED(hr
= d3dx9_base_effect_init(&compiler
->base_effect
, data
, data_size
, defines
,
5929 include
, eflags
, error_messages
, NULL
)))
5931 FIXME("Failed to parse effect, hr %#x.\n", hr
);
5932 free_effect_compiler(compiler
);
5939 HRESULT WINAPI
D3DXCreateEffectCompiler(const char *srcdata
, UINT srcdatalen
, const D3DXMACRO
*defines
,
5940 ID3DXInclude
*include
, DWORD flags
, ID3DXEffectCompiler
**compiler
, ID3DXBuffer
**parse_errors
)
5942 struct ID3DXEffectCompilerImpl
*object
;
5945 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
5946 srcdata
, srcdatalen
, defines
, include
, flags
, compiler
, parse_errors
);
5948 if (!srcdata
|| !compiler
)
5950 WARN("Invalid arguments supplied\n");
5951 return D3DERR_INVALIDCALL
;
5954 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
5956 return E_OUTOFMEMORY
;
5958 hr
= d3dx9_effect_compiler_init(object
, srcdata
, srcdatalen
, (const D3D_SHADER_MACRO
*)defines
,
5959 (ID3DInclude
*)include
, flags
, (ID3DBlob
**)parse_errors
);
5962 WARN("Failed to initialize effect compiler\n");
5963 HeapFree(GetProcessHeap(), 0, object
);
5967 *compiler
= &object
->ID3DXEffectCompiler_iface
;
5969 TRACE("Created ID3DXEffectCompiler %p\n", object
);
5974 struct ID3DXEffectPoolImpl
5976 ID3DXEffectPool ID3DXEffectPool_iface
;
5980 static inline struct ID3DXEffectPoolImpl
*impl_from_ID3DXEffectPool(ID3DXEffectPool
*iface
)
5982 return CONTAINING_RECORD(iface
, struct ID3DXEffectPoolImpl
, ID3DXEffectPool_iface
);
5985 /*** IUnknown methods ***/
5986 static HRESULT WINAPI
ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool
*iface
, REFIID riid
, void **object
)
5988 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), object
);
5990 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
5991 IsEqualGUID(riid
, &IID_ID3DXEffectPool
))
5993 iface
->lpVtbl
->AddRef(iface
);
5998 WARN("Interface %s not found\n", debugstr_guid(riid
));
6000 return E_NOINTERFACE
;
6003 static ULONG WINAPI
ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool
*iface
)
6005 struct ID3DXEffectPoolImpl
*This
= impl_from_ID3DXEffectPool(iface
);
6007 TRACE("(%p)->(): AddRef from %u\n", This
, This
->ref
);
6009 return InterlockedIncrement(&This
->ref
);
6012 static ULONG WINAPI
ID3DXEffectPoolImpl_Release(ID3DXEffectPool
*iface
)
6014 struct ID3DXEffectPoolImpl
*This
= impl_from_ID3DXEffectPool(iface
);
6015 ULONG ref
= InterlockedDecrement(&This
->ref
);
6017 TRACE("(%p)->(): Release from %u\n", This
, ref
+ 1);
6020 HeapFree(GetProcessHeap(), 0, This
);
6025 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl
=
6027 /*** IUnknown methods ***/
6028 ID3DXEffectPoolImpl_QueryInterface
,
6029 ID3DXEffectPoolImpl_AddRef
,
6030 ID3DXEffectPoolImpl_Release
6033 HRESULT WINAPI
D3DXCreateEffectPool(ID3DXEffectPool
**pool
)
6035 struct ID3DXEffectPoolImpl
*object
;
6037 TRACE("(%p)\n", pool
);
6040 return D3DERR_INVALIDCALL
;
6042 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
6044 return E_OUTOFMEMORY
;
6046 object
->ID3DXEffectPool_iface
.lpVtbl
= &ID3DXEffectPool_Vtbl
;
6049 *pool
= &object
->ID3DXEffectPool_iface
;
6054 HRESULT WINAPI
D3DXCreateEffectFromFileExW(struct IDirect3DDevice9
*device
, const WCHAR
*srcfile
,
6055 const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, const char *skipconstants
, DWORD flags
,
6056 struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
6062 TRACE("device %p, srcfile %s, defines %p, include %p, skipconstants %s, "
6063 "flags %#x, pool %p, effect %p, compilationerrors %p.\n",
6064 device
, debugstr_w(srcfile
), defines
, include
, debugstr_a(skipconstants
),
6065 flags
, pool
, effect
, compilationerrors
);
6067 if (!device
|| !srcfile
)
6068 return D3DERR_INVALIDCALL
;
6070 ret
= map_view_of_file(srcfile
, &buffer
, &size
);
6073 return D3DXERR_INVALIDDATA
;
6075 ret
= D3DXCreateEffectEx(device
, buffer
, size
, defines
, include
, skipconstants
, flags
, pool
, effect
, compilationerrors
);
6076 UnmapViewOfFile(buffer
);
6081 HRESULT WINAPI
D3DXCreateEffectFromFileExA(struct IDirect3DDevice9
*device
, const char *srcfile
,
6082 const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, const char *skipconstants
, DWORD flags
,
6083 struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
6089 TRACE("device %p, srcfile %s, defines %p, include %p, skipconstants %s, "
6090 "flags %#x, pool %p, effect %p, compilationerrors %p.\n",
6091 device
, debugstr_a(srcfile
), defines
, include
, debugstr_a(skipconstants
),
6092 flags
, pool
, effect
, compilationerrors
);
6095 return D3DERR_INVALIDCALL
;
6097 len
= MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, NULL
, 0);
6098 srcfileW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(*srcfileW
));
6099 MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, srcfileW
, len
);
6101 ret
= D3DXCreateEffectFromFileExW(device
, srcfileW
, defines
, include
, skipconstants
, flags
, pool
, effect
, compilationerrors
);
6102 HeapFree(GetProcessHeap(), 0, srcfileW
);
6107 HRESULT WINAPI
D3DXCreateEffectFromFileW(struct IDirect3DDevice9
*device
, const WCHAR
*srcfile
,
6108 const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, DWORD flags
, struct ID3DXEffectPool
*pool
,
6109 struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
6111 TRACE("(void): relay\n");
6112 return D3DXCreateEffectFromFileExW(device
, srcfile
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
6115 HRESULT WINAPI
D3DXCreateEffectFromFileA(struct IDirect3DDevice9
*device
, const char *srcfile
,
6116 const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, DWORD flags
, struct ID3DXEffectPool
*pool
,
6117 struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
6119 TRACE("(void): relay\n");
6120 return D3DXCreateEffectFromFileExA(device
, srcfile
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
6123 HRESULT WINAPI
D3DXCreateEffectFromResourceExW(struct IDirect3DDevice9
*device
, HMODULE srcmodule
,
6124 const WCHAR
*srcresource
, const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, const char *skipconstants
,
6125 DWORD flags
, struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
6131 TRACE("device %p, srcmodule %p, srcresource %s, defines %p, include %p, skipconstants %s, "
6132 "flags %#x, pool %p, effect %p, compilationerrors %p.\n",
6133 device
, srcmodule
, debugstr_w(srcresource
), defines
, include
, debugstr_a(skipconstants
),
6134 flags
, pool
, effect
, compilationerrors
);
6137 return D3DERR_INVALIDCALL
;
6139 if (!(resinfo
= FindResourceW(srcmodule
, srcresource
, (const WCHAR
*)RT_RCDATA
)))
6140 return D3DXERR_INVALIDDATA
;
6142 if (FAILED(load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
)))
6143 return D3DXERR_INVALIDDATA
;
6145 return D3DXCreateEffectEx(device
, buffer
, size
, defines
, include
,
6146 skipconstants
, flags
, pool
, effect
, compilationerrors
);
6149 HRESULT WINAPI
D3DXCreateEffectFromResourceExA(struct IDirect3DDevice9
*device
, HMODULE srcmodule
,
6150 const char *srcresource
, const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, const char *skipconstants
,
6151 DWORD flags
, struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
6157 TRACE("device %p, srcmodule %p, srcresource %s, defines %p, include %p, skipconstants %s, "
6158 "flags %#x, pool %p, effect %p, compilationerrors %p.\n",
6159 device
, srcmodule
, debugstr_a(srcresource
), defines
, include
, debugstr_a(skipconstants
),
6160 flags
, pool
, effect
, compilationerrors
);
6163 return D3DERR_INVALIDCALL
;
6165 if (!(resinfo
= FindResourceA(srcmodule
, srcresource
, (const char *)RT_RCDATA
)))
6166 return D3DXERR_INVALIDDATA
;
6168 if (FAILED(load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
)))
6169 return D3DXERR_INVALIDDATA
;
6171 return D3DXCreateEffectEx(device
, buffer
, size
, defines
, include
,
6172 skipconstants
, flags
, pool
, effect
, compilationerrors
);
6175 HRESULT WINAPI
D3DXCreateEffectFromResourceW(struct IDirect3DDevice9
*device
, HMODULE srcmodule
,
6176 const WCHAR
*srcresource
, const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, DWORD flags
,
6177 struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
6179 TRACE("(void): relay\n");
6180 return D3DXCreateEffectFromResourceExW(device
, srcmodule
, srcresource
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
6183 HRESULT WINAPI
D3DXCreateEffectFromResourceA(struct IDirect3DDevice9
*device
, HMODULE srcmodule
,
6184 const char *srcresource
, const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, DWORD flags
,
6185 struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
6187 TRACE("(void): relay\n");
6188 return D3DXCreateEffectFromResourceExA(device
, srcmodule
, srcresource
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
6191 HRESULT WINAPI
D3DXCreateEffectCompilerFromFileW(const WCHAR
*srcfile
, const D3DXMACRO
*defines
,
6192 ID3DXInclude
*include
, DWORD flags
, ID3DXEffectCompiler
**effectcompiler
, ID3DXBuffer
**parseerrors
)
6198 TRACE("srcfile %s, defines %p, include %p, flags %#x, effectcompiler %p, parseerrors %p.\n",
6199 debugstr_w(srcfile
), defines
, include
, flags
, effectcompiler
, parseerrors
);
6202 return D3DERR_INVALIDCALL
;
6204 ret
= map_view_of_file(srcfile
, &buffer
, &size
);
6207 return D3DXERR_INVALIDDATA
;
6209 ret
= D3DXCreateEffectCompiler(buffer
, size
, defines
, include
, flags
, effectcompiler
, parseerrors
);
6210 UnmapViewOfFile(buffer
);
6215 HRESULT WINAPI
D3DXCreateEffectCompilerFromFileA(const char *srcfile
, const D3DXMACRO
*defines
,
6216 ID3DXInclude
*include
, DWORD flags
, ID3DXEffectCompiler
**effectcompiler
, ID3DXBuffer
**parseerrors
)
6222 TRACE("srcfile %s, defines %p, include %p, flags %#x, effectcompiler %p, parseerrors %p.\n",
6223 debugstr_a(srcfile
), defines
, include
, flags
, effectcompiler
, parseerrors
);
6226 return D3DERR_INVALIDCALL
;
6228 len
= MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, NULL
, 0);
6229 srcfileW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(*srcfileW
));
6230 MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, srcfileW
, len
);
6232 ret
= D3DXCreateEffectCompilerFromFileW(srcfileW
, defines
, include
, flags
, effectcompiler
, parseerrors
);
6233 HeapFree(GetProcessHeap(), 0, srcfileW
);
6238 HRESULT WINAPI
D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule
, const char *srcresource
,
6239 const D3DXMACRO
*defines
, ID3DXInclude
*include
, DWORD flags
,
6240 ID3DXEffectCompiler
**effectcompiler
, ID3DXBuffer
**parseerrors
)
6246 TRACE("srcmodule %p, srcresource %s, defines %p, include %p, flags %#x, effectcompiler %p, parseerrors %p.\n",
6247 srcmodule
, debugstr_a(srcresource
), defines
, include
, flags
, effectcompiler
, parseerrors
);
6249 if (!(resinfo
= FindResourceA(srcmodule
, srcresource
, (const char *)RT_RCDATA
)))
6250 return D3DXERR_INVALIDDATA
;
6252 if (FAILED(load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
)))
6253 return D3DXERR_INVALIDDATA
;
6255 return D3DXCreateEffectCompiler(buffer
, size
, defines
, include
, flags
, effectcompiler
, parseerrors
);
6258 HRESULT WINAPI
D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule
, const WCHAR
*srcresource
,
6259 const D3DXMACRO
*defines
, ID3DXInclude
*include
, DWORD flags
,
6260 ID3DXEffectCompiler
**effectcompiler
, ID3DXBuffer
**parseerrors
)
6266 TRACE("srcmodule %p, srcresource %s, defines %p, include %p, flags %#x, effectcompiler %p, parseerrors %p.\n",
6267 srcmodule
, debugstr_w(srcresource
), defines
, include
, flags
, effectcompiler
, parseerrors
);
6269 if (!(resinfo
= FindResourceW(srcmodule
, srcresource
, (const WCHAR
*)RT_RCDATA
)))
6270 return D3DXERR_INVALIDDATA
;
6272 if (FAILED(load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
)))
6273 return D3DXERR_INVALIDDATA
;
6275 return D3DXCreateEffectCompiler(buffer
, size
, defines
, include
, flags
, effectcompiler
, parseerrors
);
6278 HRESULT WINAPI
D3DXDisassembleEffect(ID3DXEffect
*effect
, BOOL enable_color_code
, ID3DXBuffer
**disassembly
)
6280 FIXME("(%p, %u, %p): stub\n", effect
, enable_color_code
, disassembly
);
6282 return D3DXERR_INVALIDDATA
;