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
= &state
->parameter
;
2498 *param_value
= NULL
;
2501 switch (state
->type
)
2504 param
= param
->referenced_param
;
2508 *param_value
= param
->data
;
2510 case ST_ARRAY_SELECTOR
:
2512 unsigned int array_idx
;
2513 static const struct d3dx_parameter array_idx_param
=
2514 {NULL
, NULL
, NULL
, D3DXPC_SCALAR
, D3DXPT_INT
, 1, 1, 0, 0, 0, 0, sizeof(array_idx
)};
2517 if (!param
->param_eval
)
2519 FIXME("Preshader structure is null.\n");
2520 return D3DERR_INVALIDCALL
;
2522 if (FAILED(hr
= d3dx_evaluate_parameter(param
->param_eval
, &array_idx_param
, &array_idx
)))
2525 param
= param
->referenced_param
;
2526 TRACE("Array index %u.\n", array_idx
);
2527 if (array_idx
>= param
->element_count
)
2529 ERR("Computed array index %u is out of bound %u.\n", array_idx
, param
->element_count
);
2530 return D3DERR_INVALIDCALL
;
2532 param
= ¶m
->members
[array_idx
];
2534 *param_value
= param
->data
;
2539 if (param
->param_eval
)
2542 *param_value
= param
->data
;
2543 return d3dx_evaluate_parameter(param
->param_eval
, param
, *param_value
);
2547 FIXME("No preshader for FXLC parameter.\n");
2548 return D3DERR_INVALIDCALL
;
2554 static void d3dx9_set_light_parameter(enum LIGHT_TYPE op
, D3DLIGHT9
*light
, void *value
)
2558 unsigned int offset
;
2563 {FIELD_OFFSET(D3DLIGHT9
, Type
), "LC_TYPE"},
2564 {FIELD_OFFSET(D3DLIGHT9
, Diffuse
), "LT_DIFFUSE"},
2565 {FIELD_OFFSET(D3DLIGHT9
, Specular
), "LT_SPECULAR"},
2566 {FIELD_OFFSET(D3DLIGHT9
, Ambient
), "LT_AMBIENT"},
2567 {FIELD_OFFSET(D3DLIGHT9
, Position
), "LT_POSITION"},
2568 {FIELD_OFFSET(D3DLIGHT9
, Direction
), "LT_DIRECTION"},
2569 {FIELD_OFFSET(D3DLIGHT9
, Range
), "LT_RANGE"},
2570 {FIELD_OFFSET(D3DLIGHT9
, Falloff
), "LT_FALLOFF"},
2571 {FIELD_OFFSET(D3DLIGHT9
, Attenuation0
), "LT_ATTENUATION0"},
2572 {FIELD_OFFSET(D3DLIGHT9
, Attenuation1
), "LT_ATTENUATION1"},
2573 {FIELD_OFFSET(D3DLIGHT9
, Attenuation2
), "LT_ATTENUATION2"},
2574 {FIELD_OFFSET(D3DLIGHT9
, Theta
), "LT_THETA"},
2575 {FIELD_OFFSET(D3DLIGHT9
, Phi
), "LT_PHI"}
2580 TRACE("LT_TYPE %u.\n", *(D3DLIGHTTYPE
*)value
);
2581 light
->Type
= *(D3DLIGHTTYPE
*)value
;
2587 D3DCOLORVALUE c
= *(D3DCOLORVALUE
*)value
;
2589 TRACE("%s (%.8e %.8e %.8e %.8e).\n", light_tbl
[op
].name
, c
.r
, c
.g
, c
.b
, c
.a
);
2590 *(D3DCOLORVALUE
*)((BYTE
*)light
+ light_tbl
[op
].offset
) = c
;
2596 D3DVECTOR v
= *(D3DVECTOR
*)value
;
2598 TRACE("%s (%.8e %.8e %.8e).\n", light_tbl
[op
].name
, v
.x
, v
.y
, v
.z
);
2599 *(D3DVECTOR
*)((BYTE
*)light
+ light_tbl
[op
].offset
) = v
;
2604 case LT_ATTENUATION0
:
2605 case LT_ATTENUATION1
:
2606 case LT_ATTENUATION2
:
2610 float v
= *(float *)value
;
2611 TRACE("%s %.8e.\n", light_tbl
[op
].name
, v
);
2612 *(float *)((BYTE
*)light
+ light_tbl
[op
].offset
) = v
;
2616 WARN("Unknown light parameter %u.\n", op
);
2621 static void d3dx9_set_material_parameter(enum MATERIAL_TYPE op
, D3DMATERIAL9
*material
, void *value
)
2625 unsigned int offset
;
2630 {FIELD_OFFSET(D3DMATERIAL9
, Diffuse
), "MT_DIFFUSE"},
2631 {FIELD_OFFSET(D3DMATERIAL9
, Ambient
), "MT_AMBIENT"},
2632 {FIELD_OFFSET(D3DMATERIAL9
, Specular
), "MT_SPECULAR"},
2633 {FIELD_OFFSET(D3DMATERIAL9
, Emissive
), "MT_EMISSIVE"},
2634 {FIELD_OFFSET(D3DMATERIAL9
, Power
), "MT_POWER"}
2641 float v
= *(float *)value
;
2643 TRACE("%s %.8e.\n", material_tbl
[op
].name
, v
);
2644 material
->Power
= v
;
2652 D3DCOLORVALUE c
= *(D3DCOLORVALUE
*)value
;
2654 TRACE("%s, value (%.8e %.8e %.8e %.8e).\n", material_tbl
[op
].name
, c
.r
, c
.g
, c
.b
, c
.a
);
2655 *(D3DCOLORVALUE
*)((BYTE
*)material
+ material_tbl
[op
].offset
) = c
;
2659 WARN("Unknown material parameter %u.\n", op
);
2664 static HRESULT
d3dx_set_shader_const_state(IDirect3DDevice9
*device
, enum SHADER_CONSTANT_TYPE op
, UINT index
,
2665 struct d3dx_parameter
*param
, void *value_ptr
)
2669 D3DXPARAMETER_TYPE type
;
2675 {D3DXPT_FLOAT
, sizeof(float) * 4, "SCT_VSFLOAT"},
2676 {D3DXPT_BOOL
, sizeof(BOOL
), "SCT_VSBOOL"},
2677 {D3DXPT_INT
, sizeof(int) * 4, "SCT_VSINT"},
2678 {D3DXPT_FLOAT
, sizeof(float) * 4, "SCT_PSFLOAT"},
2679 {D3DXPT_BOOL
, sizeof(BOOL
), "SCT_PSBOOL"},
2680 {D3DXPT_INT
, sizeof(int) * 4, "SCT_PSINT"},
2682 unsigned int element_count
;
2684 if (op
< 0 || op
> SCT_PSINT
)
2686 FIXME("Unknown op %u.\n", op
);
2687 return D3DERR_INVALIDCALL
;
2689 element_count
= param
->bytes
/ const_tbl
[op
].elem_size
;
2690 TRACE("%s, index %u, element_count %u.\n", const_tbl
[op
].name
, index
, element_count
);
2691 if (param
->type
!= const_tbl
[op
].type
)
2693 FIXME("Unexpected param type %u.\n", param
->type
);
2694 return D3DERR_INVALIDCALL
;
2696 if (param
->bytes
% const_tbl
[op
].elem_size
!= 0)
2698 FIXME("Unexpected param size %u, rows %u, cols %u.\n", param
->bytes
, param
->rows
, param
->columns
);
2699 return D3DERR_INVALIDCALL
;
2705 return IDirect3DDevice9_SetVertexShaderConstantF(device
, index
, (const float *)value_ptr
, element_count
);
2707 return IDirect3DDevice9_SetVertexShaderConstantB(device
, index
, (const BOOL
*)value_ptr
, element_count
);
2709 return IDirect3DDevice9_SetVertexShaderConstantI(device
, index
, (const int *)value_ptr
, element_count
);
2711 return IDirect3DDevice9_SetPixelShaderConstantF(device
, index
, (const float *)value_ptr
, element_count
);
2713 return IDirect3DDevice9_SetPixelShaderConstantB(device
, index
, (const BOOL
*)value_ptr
, element_count
);
2715 return IDirect3DDevice9_SetPixelShaderConstantI(device
, index
, (const int *)value_ptr
, element_count
);
2720 static HRESULT
d3dx9_apply_state(struct ID3DXEffectImpl
*effect
, struct d3dx_pass
*pass
,
2721 struct d3dx_state
*state
, unsigned int parent_index
);
2723 static HRESULT
d3dx_set_shader_constants(struct ID3DXEffectImpl
*effect
, struct d3dx_pass
*pass
,
2724 struct d3dx_parameter
*param
, BOOL vs
)
2726 IDirect3DDevice9
*device
= effect
->device
;
2728 struct d3dx_parameter
**params
;
2729 D3DXCONSTANT_DESC
*cdesc
;
2730 unsigned int parameters_count
;
2733 if (!param
->param_eval
)
2735 FIXME("param_eval structure is null.\n");
2736 return D3DERR_INVALIDCALL
;
2738 if (FAILED(hr
= d3dx_param_eval_set_shader_constants(device
, param
->param_eval
)))
2740 params
= param
->param_eval
->shader_inputs
.inputs_param
;
2741 cdesc
= param
->param_eval
->shader_inputs
.inputs
;
2742 parameters_count
= param
->param_eval
->shader_inputs
.input_count
;
2744 for (i
= 0; i
< parameters_count
; ++i
)
2746 if (params
[i
] && params
[i
]->class == D3DXPC_OBJECT
&& (params
[i
]->type
== D3DXPT_SAMPLER
2747 || params
[i
]->type
== D3DXPT_SAMPLER1D
|| params
[i
]->type
== D3DXPT_SAMPLER2D
2748 || params
[i
]->type
== D3DXPT_SAMPLER3D
|| params
[i
]->type
== D3DXPT_SAMPLERCUBE
))
2750 struct d3dx_sampler
*sampler
;
2752 sampler
= (struct d3dx_sampler
*)params
[i
]->data
;
2753 TRACE("sampler %s, register index %u, state count %u.\n", debugstr_a(params
[i
]->name
),
2754 cdesc
[i
].RegisterIndex
, sampler
->state_count
);
2755 for (j
= 0; j
< sampler
->state_count
; ++j
)
2757 if (FAILED(hr
= d3dx9_apply_state(effect
, pass
, &sampler
->states
[j
],
2758 cdesc
[i
].RegisterIndex
+ (vs
? D3DVERTEXTEXTURESAMPLER0
: 0))))
2766 static HRESULT
d3dx9_apply_state(struct ID3DXEffectImpl
*effect
, struct d3dx_pass
*pass
,
2767 struct d3dx_state
*state
, unsigned int parent_index
)
2769 IDirect3DDevice9
*device
= effect
->device
;
2770 struct d3dx_parameter
*param
;
2774 TRACE("operation %u, index %u, type %u.\n", state
->operation
, state
->index
, state
->type
);
2775 if (FAILED(hr
= d3dx9_get_param_value_ptr(effect
, pass
, state
, ¶m_value
, ¶m
)))
2776 /* Native d3dx returns D3D_OK from BeginPass or Commit involving out of bounds array
2777 * access and does not touch affected state. */
2780 switch (state_table
[state
->operation
].class)
2782 case SC_RENDERSTATE
:
2783 TRACE("%s, operation %u, value %u.\n", state_table
[state
->operation
].name
,
2784 state_table
[state
->operation
].op
, *(DWORD
*)param_value
);
2785 return IDirect3DDevice9_SetRenderState(device
, state_table
[state
->operation
].op
, *(DWORD
*)param_value
);
2787 TRACE("%s, value %#x.\n", state_table
[state
->operation
].name
, *(DWORD
*)param_value
);
2788 return IDirect3DDevice9_SetFVF(device
, *(DWORD
*)param_value
);
2793 unit
= parent_index
== ~0u ? state
->index
: parent_index
;
2794 TRACE("%s, unit %u, value %p.\n", state_table
[state
->operation
].name
, unit
,
2795 *(IDirect3DBaseTexture9
**)param_value
);
2796 return IDirect3DDevice9_SetTexture(device
, unit
, *(IDirect3DBaseTexture9
**)param_value
);
2798 case SC_TEXTURESTAGE
:
2799 TRACE("%s, stage %u, value %u.\n", state_table
[state
->operation
].name
, state
->index
, *(DWORD
*)param_value
);
2800 return IDirect3DDevice9_SetTextureStageState(device
, state
->index
,
2801 state_table
[state
->operation
].op
, *(DWORD
*)param_value
);
2804 struct d3dx_sampler
*sampler
;
2808 sampler
= (struct d3dx_sampler
*)param_value
;
2809 TRACE("%s, sampler %u, applying %u states.\n", state_table
[state
->operation
].name
, state
->index
,
2810 sampler
->state_count
);
2812 for (i
= 0; i
< sampler
->state_count
; i
++)
2814 if (FAILED(hr
= d3dx9_apply_state(effect
, pass
, &sampler
->states
[i
], state
->index
)))
2819 case SC_SAMPLERSTATE
:
2823 sampler
= parent_index
== ~0u ? state
->index
: parent_index
;
2824 TRACE("%s, sampler %u, value %u.\n", state_table
[state
->operation
].name
, sampler
, *(DWORD
*)param_value
);
2825 return IDirect3DDevice9_SetSamplerState(device
, sampler
, state_table
[state
->operation
].op
,
2826 *(DWORD
*)param_value
);
2828 case SC_VERTEXSHADER
:
2829 TRACE("%s, shader %p.\n", state_table
[state
->operation
].name
, *(IDirect3DVertexShader9
**)param_value
);
2830 if (FAILED(hr
= IDirect3DDevice9_SetVertexShader(device
, *(IDirect3DVertexShader9
**)param_value
)))
2831 ERR("Could not set vertex shader, hr %#x.\n", hr
);
2832 else if (*(IDirect3DVertexShader9
**)param_value
)
2833 hr
= d3dx_set_shader_constants(effect
, pass
, param
, TRUE
);
2835 case SC_PIXELSHADER
:
2836 TRACE("%s, shader %p.\n", state_table
[state
->operation
].name
, *(IDirect3DPixelShader9
**)param_value
);
2837 if (FAILED(hr
= IDirect3DDevice9_SetPixelShader(device
, *(IDirect3DPixelShader9
**)param_value
)))
2838 ERR("Could not set pixel shader, hr %#x.\n", hr
);
2839 else if (*(IDirect3DPixelShader9
**)param_value
)
2840 hr
= d3dx_set_shader_constants(effect
, pass
, param
, FALSE
);
2843 TRACE("%s, state %u.\n", state_table
[state
->operation
].name
, state
->index
);
2844 return IDirect3DDevice9_SetTransform(device
, state_table
[state
->operation
].op
+ state
->index
,
2845 (D3DMATRIX
*)param_value
);
2846 case SC_LIGHTENABLE
:
2847 TRACE("%s, index %u, value %u.\n", state_table
[state
->operation
].name
, state
->index
, *(BOOL
*)param_value
);
2848 return IDirect3DDevice9_LightEnable(device
, state
->index
, *(BOOL
*)param_value
);
2853 TRACE("%s, index %u, op %u.\n", state_table
[state
->operation
].name
, state
->index
,
2854 state_table
[state
->operation
].op
);
2855 if (FAILED(hr
= IDirect3DDevice9_GetLight(device
, state
->index
, &light
)))
2857 WARN("Could not get light, hr %#x.\n", hr
);
2858 memset(&light
, 0, sizeof(light
));
2860 d3dx9_set_light_parameter(state_table
[state
->operation
].op
, &light
, param_value
);
2861 return IDirect3DDevice9_SetLight(device
, state
->index
, &light
);
2865 D3DMATERIAL9 material
;
2867 TRACE("%s, index %u, op %u.\n", state_table
[state
->operation
].name
, state
->index
,
2868 state_table
[state
->operation
].op
);
2869 if (FAILED(hr
= IDirect3DDevice9_GetMaterial(device
, &material
)))
2871 WARN("Could not get material, hr %#x.\n", hr
);
2872 memset(&material
, 0, sizeof(material
));
2874 d3dx9_set_material_parameter(state_table
[state
->operation
].op
, &material
, param_value
);
2875 return IDirect3DDevice9_SetMaterial(device
, &material
);
2878 TRACE("%s, nsegments %f.\n", state_table
[state
->operation
].name
, *(float *)param_value
);
2879 return IDirect3DDevice9_SetNPatchMode(device
, *(float *)param_value
);
2880 case SC_SHADERCONST
:
2881 TRACE("%s, index %u, op %u.\n", state_table
[state
->operation
].name
, state
->index
,
2882 state_table
[state
->operation
].op
);
2883 return d3dx_set_shader_const_state(device
, state_table
[state
->operation
].op
, state
->index
,
2884 param
, param_value
);
2886 FIXME("%s not handled.\n", state_table
[state
->operation
].name
);
2892 static HRESULT
d3dx9_apply_pass_states(struct ID3DXEffectImpl
*effect
, struct d3dx_pass
*pass
)
2897 TRACE("effect %p, pass %p, state_count %u.\n", effect
, pass
, pass
->state_count
);
2900 for (i
= 0; i
< pass
->state_count
; i
++)
2904 if (FAILED(hr
= d3dx9_apply_state(effect
, pass
, &pass
->states
[i
], ~0u)))
2906 WARN("Error applying state, hr %#x.\n", hr
);
2913 static inline struct ID3DXEffectImpl
*impl_from_ID3DXEffect(ID3DXEffect
*iface
)
2915 return CONTAINING_RECORD(iface
, struct ID3DXEffectImpl
, ID3DXEffect_iface
);
2918 /*** IUnknown methods ***/
2919 static HRESULT WINAPI
ID3DXEffectImpl_QueryInterface(ID3DXEffect
*iface
, REFIID riid
, void **object
)
2921 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), object
);
2923 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
2924 IsEqualGUID(riid
, &IID_ID3DXEffect
))
2926 iface
->lpVtbl
->AddRef(iface
);
2931 ERR("Interface %s not found\n", debugstr_guid(riid
));
2933 return E_NOINTERFACE
;
2936 static ULONG WINAPI
ID3DXEffectImpl_AddRef(ID3DXEffect
*iface
)
2938 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2940 TRACE("(%p)->(): AddRef from %u\n", This
, This
->ref
);
2942 return InterlockedIncrement(&This
->ref
);
2945 static ULONG WINAPI
ID3DXEffectImpl_Release(ID3DXEffect
*iface
)
2947 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
2948 ULONG ref
= InterlockedDecrement(&This
->ref
);
2950 TRACE("(%p)->(): Release from %u\n", This
, ref
+ 1);
2955 HeapFree(GetProcessHeap(), 0, This
);
2961 /*** ID3DXBaseEffect methods ***/
2962 static HRESULT WINAPI
ID3DXEffectImpl_GetDesc(ID3DXEffect
*iface
, D3DXEFFECT_DESC
*desc
)
2964 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2966 TRACE("iface %p, desc %p.\n", iface
, desc
);
2968 return d3dx9_base_effect_get_desc(&effect
->base_effect
, desc
);
2971 static HRESULT WINAPI
ID3DXEffectImpl_GetParameterDesc(ID3DXEffect
*iface
,
2972 D3DXHANDLE parameter
, D3DXPARAMETER_DESC
*desc
)
2974 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2976 TRACE("iface %p, parameter %p, desc %p.\n", iface
, parameter
, desc
);
2978 return d3dx9_base_effect_get_parameter_desc(&effect
->base_effect
, parameter
, desc
);
2981 static HRESULT WINAPI
ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect
*iface
,
2982 D3DXHANDLE technique
, D3DXTECHNIQUE_DESC
*desc
)
2984 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2986 TRACE("iface %p, technique %p, desc %p.\n", iface
, technique
, desc
);
2988 return d3dx9_base_effect_get_technique_desc(&effect
->base_effect
, technique
, desc
);
2991 static HRESULT WINAPI
ID3DXEffectImpl_GetPassDesc(ID3DXEffect
*iface
, D3DXHANDLE pass
, D3DXPASS_DESC
*desc
)
2993 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
2995 TRACE("iface %p, pass %p, desc %p.\n", iface
, pass
, desc
);
2997 return d3dx9_base_effect_get_pass_desc(&effect
->base_effect
, pass
, desc
);
3000 static HRESULT WINAPI
ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect
*iface
, D3DXHANDLE shader
, D3DXFUNCTION_DESC
*desc
)
3002 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3004 TRACE("iface %p, shader %p, desc %p.\n", iface
, shader
, desc
);
3006 return d3dx9_base_effect_get_function_desc(&effect
->base_effect
, shader
, desc
);
3009 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameter(ID3DXEffect
*iface
, D3DXHANDLE parameter
, UINT index
)
3011 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3013 TRACE("iface %p, parameter %p, index %u.\n", iface
, parameter
, index
);
3015 return d3dx9_base_effect_get_parameter(&effect
->base_effect
, parameter
, index
);
3018 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameterByName(ID3DXEffect
*iface
,
3019 D3DXHANDLE parameter
, const char *name
)
3021 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3023 TRACE("iface %p, parameter %p, name %s.\n", iface
, parameter
, debugstr_a(name
));
3025 return d3dx9_base_effect_get_parameter_by_name(&effect
->base_effect
, parameter
, name
);
3028 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect
*iface
,
3029 D3DXHANDLE parameter
, const char *semantic
)
3031 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3033 TRACE("iface %p, parameter %p, semantic %s.\n", iface
, parameter
, debugstr_a(semantic
));
3035 return d3dx9_base_effect_get_parameter_by_semantic(&effect
->base_effect
, parameter
, semantic
);
3038 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetParameterElement(ID3DXEffect
*iface
, D3DXHANDLE parameter
, UINT index
)
3040 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3042 TRACE("iface %p, parameter %p, index %u.\n", iface
, parameter
, index
);
3044 return d3dx9_base_effect_get_parameter_element(&effect
->base_effect
, parameter
, index
);
3047 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetTechnique(ID3DXEffect
*iface
, UINT index
)
3049 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3051 TRACE("iface %p, index %u.\n", iface
, index
);
3053 return d3dx9_base_effect_get_technique(&effect
->base_effect
, index
);
3056 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect
*iface
, const char *name
)
3058 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3060 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
3062 return d3dx9_base_effect_get_technique_by_name(&effect
->base_effect
, name
);
3065 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetPass(ID3DXEffect
*iface
, D3DXHANDLE technique
, UINT index
)
3067 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3069 TRACE("iface %p, technique %p, index %u.\n", iface
, technique
, index
);
3071 return d3dx9_base_effect_get_pass(&effect
->base_effect
, technique
, index
);
3074 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetPassByName(ID3DXEffect
*iface
,
3075 D3DXHANDLE technique
, const char *name
)
3077 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3079 TRACE("iface %p, technique %p, name %s.\n", iface
, technique
, debugstr_a(name
));
3081 return d3dx9_base_effect_get_pass_by_name(&effect
->base_effect
, technique
, name
);
3084 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetFunction(ID3DXEffect
*iface
, UINT index
)
3086 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3088 TRACE("iface %p, index %u.\n", iface
, index
);
3090 return d3dx9_base_effect_get_function(&effect
->base_effect
, index
);
3093 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetFunctionByName(ID3DXEffect
*iface
, const char *name
)
3095 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3097 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
3099 return d3dx9_base_effect_get_function_by_name(&effect
->base_effect
, name
);
3102 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetAnnotation(ID3DXEffect
*iface
, D3DXHANDLE object
, UINT index
)
3104 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3106 TRACE("iface %p, object %p, index %u.\n", iface
, object
, index
);
3108 return d3dx9_base_effect_get_annotation(&effect
->base_effect
, object
, index
);
3111 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect
*iface
,
3112 D3DXHANDLE object
, const char *name
)
3114 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3116 TRACE("iface %p, object %p, name %s.\n", iface
, object
, debugstr_a(name
));
3118 return d3dx9_base_effect_get_annotation_by_name(&effect
->base_effect
, object
, name
);
3121 static HRESULT WINAPI
ID3DXEffectImpl_SetValue(ID3DXEffect
*iface
,
3122 D3DXHANDLE parameter
, const void *data
, UINT bytes
)
3124 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3126 TRACE("iface %p, parameter %p, data %p, bytes %u.\n", iface
, parameter
, data
, bytes
);
3128 return d3dx9_base_effect_set_value(&effect
->base_effect
, parameter
, data
, bytes
);
3131 static HRESULT WINAPI
ID3DXEffectImpl_GetValue(ID3DXEffect
*iface
,
3132 D3DXHANDLE parameter
, void *data
, UINT bytes
)
3134 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3136 TRACE("iface %p, parameter %p, data %p, bytes %u.\n", iface
, parameter
, data
, bytes
);
3138 return d3dx9_base_effect_get_value(&effect
->base_effect
, parameter
, data
, bytes
);
3141 static HRESULT WINAPI
ID3DXEffectImpl_SetBool(ID3DXEffect
*iface
, D3DXHANDLE parameter
, BOOL b
)
3143 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3145 TRACE("iface %p, parameter %p, b %#x.\n", iface
, parameter
, b
);
3147 return d3dx9_base_effect_set_bool(&effect
->base_effect
, parameter
, b
);
3150 static HRESULT WINAPI
ID3DXEffectImpl_GetBool(ID3DXEffect
*iface
, D3DXHANDLE parameter
, BOOL
*b
)
3152 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3154 TRACE("iface %p, parameter %p, b %p.\n", iface
, parameter
, b
);
3156 return d3dx9_base_effect_get_bool(&effect
->base_effect
, parameter
, b
);
3159 static HRESULT WINAPI
ID3DXEffectImpl_SetBoolArray(ID3DXEffect
*iface
,
3160 D3DXHANDLE parameter
, const BOOL
*b
, UINT count
)
3162 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3164 TRACE("iface %p, parameter %p, b %p, count %u.\n", iface
, parameter
, b
, count
);
3166 return d3dx9_base_effect_set_bool_array(&effect
->base_effect
, parameter
, b
, count
);
3169 static HRESULT WINAPI
ID3DXEffectImpl_GetBoolArray(ID3DXEffect
*iface
,
3170 D3DXHANDLE parameter
, BOOL
*b
, UINT count
)
3172 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3174 TRACE("iface %p, parameter %p, b %p, count %u.\n", iface
, parameter
, b
, count
);
3176 return d3dx9_base_effect_get_bool_array(&effect
->base_effect
, parameter
, b
, count
);
3179 static HRESULT WINAPI
ID3DXEffectImpl_SetInt(ID3DXEffect
*iface
, D3DXHANDLE parameter
, INT n
)
3181 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3183 TRACE("iface %p, parameter %p, n %d.\n", iface
, parameter
, n
);
3185 return d3dx9_base_effect_set_int(&effect
->base_effect
, parameter
, n
);
3188 static HRESULT WINAPI
ID3DXEffectImpl_GetInt(ID3DXEffect
*iface
, D3DXHANDLE parameter
, INT
*n
)
3190 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3192 TRACE("iface %p, parameter %p, n %p.\n", iface
, parameter
, n
);
3194 return d3dx9_base_effect_get_int(&effect
->base_effect
, parameter
, n
);
3197 static HRESULT WINAPI
ID3DXEffectImpl_SetIntArray(ID3DXEffect
*iface
,
3198 D3DXHANDLE parameter
, const INT
*n
, UINT count
)
3200 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3202 TRACE("iface %p, parameter %p, n %p, count %u.\n", iface
, parameter
, n
, count
);
3204 return d3dx9_base_effect_set_int_array(&effect
->base_effect
, parameter
, n
, count
);
3207 static HRESULT WINAPI
ID3DXEffectImpl_GetIntArray(ID3DXEffect
*iface
,
3208 D3DXHANDLE parameter
, INT
*n
, UINT count
)
3210 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3212 TRACE("iface %p, parameter %p, n %p, count %u.\n", iface
, parameter
, n
, count
);
3214 return d3dx9_base_effect_get_int_array(&effect
->base_effect
, parameter
, n
, count
);
3217 static HRESULT WINAPI
ID3DXEffectImpl_SetFloat(ID3DXEffect
*iface
, D3DXHANDLE parameter
, float f
)
3219 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3221 TRACE("iface %p, parameter %p, f %.8e.\n", iface
, parameter
, f
);
3223 return d3dx9_base_effect_set_float(&effect
->base_effect
, parameter
, f
);
3226 static HRESULT WINAPI
ID3DXEffectImpl_GetFloat(ID3DXEffect
*iface
, D3DXHANDLE parameter
, float *f
)
3228 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3230 TRACE("iface %p, parameter %p, f %p.\n", iface
, parameter
, f
);
3232 return d3dx9_base_effect_get_float(&effect
->base_effect
, parameter
, f
);
3235 static HRESULT WINAPI
ID3DXEffectImpl_SetFloatArray(ID3DXEffect
*iface
,
3236 D3DXHANDLE parameter
, const float *f
, UINT count
)
3238 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3240 TRACE("iface %p, parameter %p, f %p, count %u.\n", iface
, parameter
, f
, count
);
3242 return d3dx9_base_effect_set_float_array(&effect
->base_effect
, parameter
, f
, count
);
3245 static HRESULT WINAPI
ID3DXEffectImpl_GetFloatArray(ID3DXEffect
*iface
,
3246 D3DXHANDLE parameter
, float *f
, UINT count
)
3248 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3250 TRACE("iface %p, parameter %p, f %p, count %u.\n", iface
, parameter
, f
, count
);
3252 return d3dx9_base_effect_get_float_array(&effect
->base_effect
, parameter
, f
, count
);
3255 static HRESULT WINAPI
ID3DXEffectImpl_SetVector(ID3DXEffect
*iface
,
3256 D3DXHANDLE parameter
, const D3DXVECTOR4
*vector
)
3258 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3260 TRACE("iface %p, parameter %p, vector %p.\n", iface
, parameter
, vector
);
3262 return d3dx9_base_effect_set_vector(&effect
->base_effect
, parameter
, vector
);
3265 static HRESULT WINAPI
ID3DXEffectImpl_GetVector(ID3DXEffect
*iface
,
3266 D3DXHANDLE parameter
, D3DXVECTOR4
*vector
)
3268 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3270 TRACE("iface %p, parameter %p, vector %p.\n", iface
, parameter
, vector
);
3272 return d3dx9_base_effect_get_vector(&effect
->base_effect
, parameter
, vector
);
3275 static HRESULT WINAPI
ID3DXEffectImpl_SetVectorArray(ID3DXEffect
*iface
,
3276 D3DXHANDLE parameter
, const D3DXVECTOR4
*vector
, UINT count
)
3278 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3280 TRACE("iface %p, parameter %p, vector %p, count %u.\n", iface
, parameter
, vector
, count
);
3282 return d3dx9_base_effect_set_vector_array(&effect
->base_effect
, parameter
, vector
, count
);
3285 static HRESULT WINAPI
ID3DXEffectImpl_GetVectorArray(ID3DXEffect
*iface
,
3286 D3DXHANDLE parameter
, D3DXVECTOR4
*vector
, UINT count
)
3288 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3290 TRACE("iface %p, parameter %p, vector %p, count %u.\n", iface
, parameter
, vector
, count
);
3292 return d3dx9_base_effect_get_vector_array(&effect
->base_effect
, parameter
, vector
, count
);
3295 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrix(ID3DXEffect
*iface
,
3296 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
)
3298 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3300 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
3302 return d3dx9_base_effect_set_matrix(&effect
->base_effect
, parameter
, matrix
);
3305 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrix(ID3DXEffect
*iface
,
3306 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
3308 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3310 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
3312 return d3dx9_base_effect_get_matrix(&effect
->base_effect
, parameter
, matrix
);
3315 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixArray(ID3DXEffect
*iface
,
3316 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
, UINT count
)
3318 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3320 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3322 return d3dx9_base_effect_set_matrix_array(&effect
->base_effect
, parameter
, matrix
, count
);
3325 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixArray(ID3DXEffect
*iface
,
3326 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
3328 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3330 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3332 return d3dx9_base_effect_get_matrix_array(&effect
->base_effect
, parameter
, matrix
, count
);
3335 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect
*iface
,
3336 D3DXHANDLE parameter
, const D3DXMATRIX
**matrix
, UINT count
)
3338 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3340 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3342 return d3dx9_base_effect_set_matrix_pointer_array(&effect
->base_effect
, parameter
, matrix
, count
);
3345 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect
*iface
,
3346 D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
3348 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3350 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3352 return d3dx9_base_effect_get_matrix_pointer_array(&effect
->base_effect
, parameter
, matrix
, count
);
3355 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect
*iface
,
3356 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
)
3358 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3360 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
3362 return d3dx9_base_effect_set_matrix_transpose(&effect
->base_effect
, parameter
, matrix
);
3365 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect
*iface
,
3366 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
3368 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3370 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
3372 return d3dx9_base_effect_get_matrix_transpose(&effect
->base_effect
, parameter
, matrix
);
3375 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect
*iface
,
3376 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
, UINT count
)
3378 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3380 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3382 return d3dx9_base_effect_set_matrix_transpose_array(&effect
->base_effect
, parameter
, matrix
, count
);
3385 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect
*iface
,
3386 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
3388 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3390 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3392 return d3dx9_base_effect_get_matrix_transpose_array(&effect
->base_effect
, parameter
, matrix
, count
);
3395 static HRESULT WINAPI
ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect
*iface
,
3396 D3DXHANDLE parameter
, const D3DXMATRIX
**matrix
, UINT count
)
3398 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3400 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3402 return d3dx9_base_effect_set_matrix_transpose_pointer_array(&effect
->base_effect
, parameter
, matrix
, count
);
3405 static HRESULT WINAPI
ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect
*iface
,
3406 D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
3408 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3410 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
3412 return d3dx9_base_effect_get_matrix_transpose_pointer_array(&effect
->base_effect
, parameter
, matrix
, count
);
3415 static HRESULT WINAPI
ID3DXEffectImpl_SetString(ID3DXEffect
*iface
, D3DXHANDLE parameter
, const char *string
)
3417 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3419 TRACE("iface %p, parameter %p, string %s.\n", iface
, parameter
, debugstr_a(string
));
3421 return d3dx9_base_effect_set_string(&effect
->base_effect
, parameter
, string
);
3424 static HRESULT WINAPI
ID3DXEffectImpl_GetString(ID3DXEffect
*iface
, D3DXHANDLE parameter
, const char **string
)
3426 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3428 TRACE("iface %p, parameter %p, string %p.\n", iface
, parameter
, string
);
3430 return d3dx9_base_effect_get_string(&effect
->base_effect
, parameter
, string
);
3433 static HRESULT WINAPI
ID3DXEffectImpl_SetTexture(struct ID3DXEffect
*iface
,
3434 D3DXHANDLE parameter
, struct IDirect3DBaseTexture9
*texture
)
3436 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3438 TRACE("iface %p, parameter %p, texture %p.\n", iface
, parameter
, texture
);
3440 return d3dx9_base_effect_set_texture(&effect
->base_effect
, parameter
, texture
);
3443 static HRESULT WINAPI
ID3DXEffectImpl_GetTexture(struct ID3DXEffect
*iface
,
3444 D3DXHANDLE parameter
, struct IDirect3DBaseTexture9
**texture
)
3446 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3448 TRACE("iface %p, parameter %p, texture %p.\n", iface
, parameter
, texture
);
3450 return d3dx9_base_effect_get_texture(&effect
->base_effect
, parameter
, texture
);
3453 static HRESULT WINAPI
ID3DXEffectImpl_GetPixelShader(ID3DXEffect
*iface
,
3454 D3DXHANDLE parameter
, struct IDirect3DPixelShader9
**shader
)
3456 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3458 TRACE("iface %p, parameter %p, shader %p.\n", iface
, parameter
, shader
);
3460 return d3dx9_base_effect_get_pixel_shader(&effect
->base_effect
, parameter
, shader
);
3463 static HRESULT WINAPI
ID3DXEffectImpl_GetVertexShader(struct ID3DXEffect
*iface
,
3464 D3DXHANDLE parameter
, struct IDirect3DVertexShader9
**shader
)
3466 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3468 TRACE("iface %p, parameter %p, shader %p.\n", iface
, parameter
, shader
);
3470 return d3dx9_base_effect_get_vertex_shader(&effect
->base_effect
, parameter
, shader
);
3473 static HRESULT WINAPI
ID3DXEffectImpl_SetArrayRange(ID3DXEffect
*iface
, D3DXHANDLE parameter
, UINT start
, UINT end
)
3475 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3477 TRACE("iface %p, parameter %p, start %u, end %u.\n", iface
, parameter
, start
, end
);
3479 return d3dx9_base_effect_set_array_range(&effect
->base_effect
, parameter
, start
, end
);
3482 /*** ID3DXEffect methods ***/
3483 static HRESULT WINAPI
ID3DXEffectImpl_GetPool(ID3DXEffect
*iface
, ID3DXEffectPool
**pool
)
3485 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3487 TRACE("iface %p, pool %p\n", This
, pool
);
3491 WARN("Invalid argument supplied.\n");
3492 return D3DERR_INVALIDCALL
;
3497 This
->pool
->lpVtbl
->AddRef(This
->pool
);
3502 TRACE("Returning pool %p\n", *pool
);
3507 static HRESULT WINAPI
ID3DXEffectImpl_SetTechnique(ID3DXEffect
*iface
, D3DXHANDLE technique
)
3509 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3510 struct d3dx9_base_effect
*base
= &This
->base_effect
;
3511 struct d3dx_technique
*tech
= get_valid_technique(base
, technique
);
3513 TRACE("iface %p, technique %p\n", This
, technique
);
3517 This
->active_technique
= tech
;
3518 TRACE("Technique %p\n", tech
);
3522 WARN("Technique not found.\n");
3524 return D3DERR_INVALIDCALL
;
3527 static D3DXHANDLE WINAPI
ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect
*iface
)
3529 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3531 TRACE("iface %p\n", This
);
3533 return get_technique_handle(This
->active_technique
);
3536 static HRESULT WINAPI
ID3DXEffectImpl_ValidateTechnique(ID3DXEffect
* iface
, D3DXHANDLE technique
)
3538 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3540 FIXME("(%p)->(%p): stub\n", This
, technique
);
3545 static HRESULT WINAPI
ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect
* iface
, D3DXHANDLE technique
, D3DXHANDLE
* next_technique
)
3547 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3549 FIXME("(%p)->(%p, %p): stub\n", This
, technique
, next_technique
);
3554 static BOOL WINAPI
ID3DXEffectImpl_IsParameterUsed(ID3DXEffect
* iface
, D3DXHANDLE parameter
, D3DXHANDLE technique
)
3556 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3557 struct d3dx_parameter
*param
= get_valid_parameter(&effect
->base_effect
, parameter
);
3559 FIXME("iface %p, parameter %p, technique %p stub.\n", iface
, parameter
, technique
);
3560 TRACE("param %p (%s).\n", param
, param
? debugstr_a(param
->name
) : "");
3565 static HRESULT WINAPI
ID3DXEffectImpl_Begin(ID3DXEffect
*iface
, UINT
*passes
, DWORD flags
)
3567 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3568 struct d3dx_technique
*technique
= effect
->active_technique
;
3570 TRACE("iface %p, passes %p, flags %#x.\n", iface
, passes
, flags
);
3572 if (passes
&& technique
)
3574 if (flags
& ~(D3DXFX_DONOTSAVESTATE
| D3DXFX_DONOTSAVESAMPLERSTATE
| D3DXFX_DONOTSAVESHADERSTATE
))
3575 WARN("Invalid flags (%#x) specified.\n", flags
);
3577 if (effect
->manager
|| flags
& D3DXFX_DONOTSAVESTATE
)
3579 TRACE("State capturing disabled.\n");
3586 if (!technique
->saved_state
)
3588 if (FAILED(hr
= IDirect3DDevice9_BeginStateBlock(effect
->device
)))
3589 ERR("BeginStateBlock failed, hr %#x.\n", hr
);
3590 for (i
= 0; i
< technique
->pass_count
; i
++)
3591 d3dx9_apply_pass_states(effect
, &technique
->passes
[i
]);
3592 if (FAILED(hr
= IDirect3DDevice9_EndStateBlock(effect
->device
, &technique
->saved_state
)))
3593 ERR("EndStateBlock failed, hr %#x.\n", hr
);
3595 if (FAILED(hr
= IDirect3DStateBlock9_Capture(technique
->saved_state
)))
3596 ERR("StateBlock Capture failed, hr %#x.\n", hr
);
3599 *passes
= technique
->pass_count
;
3600 effect
->started
= TRUE
;
3601 effect
->flags
= flags
;
3606 WARN("Invalid argument supplied.\n");
3608 return D3DERR_INVALIDCALL
;
3611 static HRESULT WINAPI
ID3DXEffectImpl_BeginPass(ID3DXEffect
*iface
, UINT pass
)
3613 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3614 struct d3dx_technique
*technique
= effect
->active_technique
;
3616 TRACE("iface %p, pass %u\n", effect
, pass
);
3618 if (technique
&& pass
< technique
->pass_count
&& !effect
->active_pass
)
3620 effect
->active_pass
= &technique
->passes
[pass
];
3621 return d3dx9_apply_pass_states(effect
, effect
->active_pass
);
3624 WARN("Invalid argument supplied.\n");
3626 return D3DERR_INVALIDCALL
;
3629 static HRESULT WINAPI
ID3DXEffectImpl_CommitChanges(ID3DXEffect
*iface
)
3631 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3633 TRACE("iface %p.\n", iface
);
3635 if (!effect
->active_pass
)
3637 WARN("Called without an active pass.\n");
3640 /* TODO: apply only changed states */
3641 return d3dx9_apply_pass_states(effect
, effect
->active_pass
);
3644 static HRESULT WINAPI
ID3DXEffectImpl_EndPass(ID3DXEffect
*iface
)
3646 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3648 TRACE("iface %p\n", This
);
3650 if (This
->active_pass
)
3652 This
->active_pass
= NULL
;
3656 WARN("Invalid call.\n");
3658 return D3DERR_INVALIDCALL
;
3661 static HRESULT WINAPI
ID3DXEffectImpl_End(ID3DXEffect
*iface
)
3663 struct ID3DXEffectImpl
*effect
= impl_from_ID3DXEffect(iface
);
3664 struct d3dx_technique
*technique
= effect
->active_technique
;
3666 TRACE("iface %p.\n", iface
);
3668 if (!effect
->started
)
3671 if (effect
->manager
|| effect
->flags
& D3DXFX_DONOTSAVESTATE
)
3673 TRACE("State restoring disabled.\n");
3679 if (technique
&& technique
->saved_state
)
3681 if (FAILED(hr
= IDirect3DStateBlock9_Apply(technique
->saved_state
)))
3682 ERR("State block apply failed, hr %#x.\n", hr
);
3685 ERR("No saved state.\n");
3688 effect
->started
= FALSE
;
3693 static HRESULT WINAPI
ID3DXEffectImpl_GetDevice(ID3DXEffect
*iface
, struct IDirect3DDevice9
**device
)
3695 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3697 TRACE("iface %p, device %p\n", This
, device
);
3701 WARN("Invalid argument supplied.\n");
3702 return D3DERR_INVALIDCALL
;
3705 IDirect3DDevice9_AddRef(This
->device
);
3707 *device
= This
->device
;
3709 TRACE("Returning device %p\n", *device
);
3714 static HRESULT WINAPI
ID3DXEffectImpl_OnLostDevice(ID3DXEffect
* iface
)
3716 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3718 FIXME("(%p)->(): stub\n", This
);
3723 static HRESULT WINAPI
ID3DXEffectImpl_OnResetDevice(ID3DXEffect
* iface
)
3725 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3727 FIXME("(%p)->(): stub\n", This
);
3732 static HRESULT WINAPI
ID3DXEffectImpl_SetStateManager(ID3DXEffect
*iface
, ID3DXEffectStateManager
*manager
)
3734 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3736 TRACE("iface %p, manager %p\n", This
, manager
);
3738 if (manager
) IUnknown_AddRef(manager
);
3739 if (This
->manager
) IUnknown_Release(This
->manager
);
3741 This
->manager
= manager
;
3746 static HRESULT WINAPI
ID3DXEffectImpl_GetStateManager(ID3DXEffect
*iface
, ID3DXEffectStateManager
**manager
)
3748 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3750 TRACE("iface %p, manager %p\n", This
, manager
);
3754 WARN("Invalid argument supplied.\n");
3755 return D3DERR_INVALIDCALL
;
3758 if (This
->manager
) IUnknown_AddRef(This
->manager
);
3759 *manager
= This
->manager
;
3764 static HRESULT WINAPI
ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect
* iface
)
3766 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3768 FIXME("(%p)->(): stub\n", This
);
3773 static D3DXHANDLE WINAPI
ID3DXEffectImpl_EndParameterBlock(ID3DXEffect
* iface
)
3775 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3777 FIXME("(%p)->(): stub\n", This
);
3782 static HRESULT WINAPI
ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect
* iface
, D3DXHANDLE parameter_block
)
3784 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3786 FIXME("(%p)->(%p): stub\n", This
, parameter_block
);
3791 static HRESULT WINAPI
ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect
* iface
, D3DXHANDLE parameter_block
)
3793 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3795 FIXME("(%p)->(%p): stub\n", This
, parameter_block
);
3800 static HRESULT WINAPI
ID3DXEffectImpl_CloneEffect(ID3DXEffect
*iface
,
3801 struct IDirect3DDevice9
*device
, struct ID3DXEffect
**effect
)
3803 struct ID3DXEffectImpl
*This
= impl_from_ID3DXEffect(iface
);
3805 FIXME("(%p)->(%p, %p): stub\n", This
, device
, effect
);
3810 static HRESULT WINAPI
ID3DXEffectImpl_SetRawValue(ID3DXEffect
*iface
,
3811 D3DXHANDLE parameter
, const void *data
, UINT byte_offset
, UINT bytes
)
3813 FIXME("iface %p, parameter %p, data %p, byte_offset %u, bytes %u stub!\n",
3814 iface
, parameter
, data
, byte_offset
, bytes
);
3819 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl
=
3821 /*** IUnknown methods ***/
3822 ID3DXEffectImpl_QueryInterface
,
3823 ID3DXEffectImpl_AddRef
,
3824 ID3DXEffectImpl_Release
,
3825 /*** ID3DXBaseEffect methods ***/
3826 ID3DXEffectImpl_GetDesc
,
3827 ID3DXEffectImpl_GetParameterDesc
,
3828 ID3DXEffectImpl_GetTechniqueDesc
,
3829 ID3DXEffectImpl_GetPassDesc
,
3830 ID3DXEffectImpl_GetFunctionDesc
,
3831 ID3DXEffectImpl_GetParameter
,
3832 ID3DXEffectImpl_GetParameterByName
,
3833 ID3DXEffectImpl_GetParameterBySemantic
,
3834 ID3DXEffectImpl_GetParameterElement
,
3835 ID3DXEffectImpl_GetTechnique
,
3836 ID3DXEffectImpl_GetTechniqueByName
,
3837 ID3DXEffectImpl_GetPass
,
3838 ID3DXEffectImpl_GetPassByName
,
3839 ID3DXEffectImpl_GetFunction
,
3840 ID3DXEffectImpl_GetFunctionByName
,
3841 ID3DXEffectImpl_GetAnnotation
,
3842 ID3DXEffectImpl_GetAnnotationByName
,
3843 ID3DXEffectImpl_SetValue
,
3844 ID3DXEffectImpl_GetValue
,
3845 ID3DXEffectImpl_SetBool
,
3846 ID3DXEffectImpl_GetBool
,
3847 ID3DXEffectImpl_SetBoolArray
,
3848 ID3DXEffectImpl_GetBoolArray
,
3849 ID3DXEffectImpl_SetInt
,
3850 ID3DXEffectImpl_GetInt
,
3851 ID3DXEffectImpl_SetIntArray
,
3852 ID3DXEffectImpl_GetIntArray
,
3853 ID3DXEffectImpl_SetFloat
,
3854 ID3DXEffectImpl_GetFloat
,
3855 ID3DXEffectImpl_SetFloatArray
,
3856 ID3DXEffectImpl_GetFloatArray
,
3857 ID3DXEffectImpl_SetVector
,
3858 ID3DXEffectImpl_GetVector
,
3859 ID3DXEffectImpl_SetVectorArray
,
3860 ID3DXEffectImpl_GetVectorArray
,
3861 ID3DXEffectImpl_SetMatrix
,
3862 ID3DXEffectImpl_GetMatrix
,
3863 ID3DXEffectImpl_SetMatrixArray
,
3864 ID3DXEffectImpl_GetMatrixArray
,
3865 ID3DXEffectImpl_SetMatrixPointerArray
,
3866 ID3DXEffectImpl_GetMatrixPointerArray
,
3867 ID3DXEffectImpl_SetMatrixTranspose
,
3868 ID3DXEffectImpl_GetMatrixTranspose
,
3869 ID3DXEffectImpl_SetMatrixTransposeArray
,
3870 ID3DXEffectImpl_GetMatrixTransposeArray
,
3871 ID3DXEffectImpl_SetMatrixTransposePointerArray
,
3872 ID3DXEffectImpl_GetMatrixTransposePointerArray
,
3873 ID3DXEffectImpl_SetString
,
3874 ID3DXEffectImpl_GetString
,
3875 ID3DXEffectImpl_SetTexture
,
3876 ID3DXEffectImpl_GetTexture
,
3877 ID3DXEffectImpl_GetPixelShader
,
3878 ID3DXEffectImpl_GetVertexShader
,
3879 ID3DXEffectImpl_SetArrayRange
,
3880 /*** ID3DXEffect methods ***/
3881 ID3DXEffectImpl_GetPool
,
3882 ID3DXEffectImpl_SetTechnique
,
3883 ID3DXEffectImpl_GetCurrentTechnique
,
3884 ID3DXEffectImpl_ValidateTechnique
,
3885 ID3DXEffectImpl_FindNextValidTechnique
,
3886 ID3DXEffectImpl_IsParameterUsed
,
3887 ID3DXEffectImpl_Begin
,
3888 ID3DXEffectImpl_BeginPass
,
3889 ID3DXEffectImpl_CommitChanges
,
3890 ID3DXEffectImpl_EndPass
,
3891 ID3DXEffectImpl_End
,
3892 ID3DXEffectImpl_GetDevice
,
3893 ID3DXEffectImpl_OnLostDevice
,
3894 ID3DXEffectImpl_OnResetDevice
,
3895 ID3DXEffectImpl_SetStateManager
,
3896 ID3DXEffectImpl_GetStateManager
,
3897 ID3DXEffectImpl_BeginParameterBlock
,
3898 ID3DXEffectImpl_EndParameterBlock
,
3899 ID3DXEffectImpl_ApplyParameterBlock
,
3900 ID3DXEffectImpl_DeleteParameterBlock
,
3901 ID3DXEffectImpl_CloneEffect
,
3902 ID3DXEffectImpl_SetRawValue
3905 static inline struct ID3DXEffectCompilerImpl
*impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler
*iface
)
3907 return CONTAINING_RECORD(iface
, struct ID3DXEffectCompilerImpl
, ID3DXEffectCompiler_iface
);
3910 /*** IUnknown methods ***/
3911 static HRESULT WINAPI
ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler
*iface
, REFIID riid
, void **object
)
3913 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), object
);
3915 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
3916 IsEqualGUID(riid
, &IID_ID3DXEffectCompiler
))
3918 iface
->lpVtbl
->AddRef(iface
);
3923 ERR("Interface %s not found\n", debugstr_guid(riid
));
3925 return E_NOINTERFACE
;
3928 static ULONG WINAPI
ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler
*iface
)
3930 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3932 TRACE("iface %p: AddRef from %u\n", iface
, This
->ref
);
3934 return InterlockedIncrement(&This
->ref
);
3937 static ULONG WINAPI
ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler
*iface
)
3939 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
3940 ULONG ref
= InterlockedDecrement(&This
->ref
);
3942 TRACE("iface %p: Release from %u\n", iface
, ref
+ 1);
3946 free_effect_compiler(This
);
3947 HeapFree(GetProcessHeap(), 0, This
);
3953 /*** ID3DXBaseEffect methods ***/
3954 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler
*iface
, D3DXEFFECT_DESC
*desc
)
3956 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3958 TRACE("iface %p, desc %p.\n", iface
, desc
);
3960 return d3dx9_base_effect_get_desc(&compiler
->base_effect
, desc
);
3963 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler
*iface
,
3964 D3DXHANDLE parameter
, D3DXPARAMETER_DESC
*desc
)
3966 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3968 TRACE("iface %p, parameter %p, desc %p.\n", iface
, parameter
, desc
);
3970 return d3dx9_base_effect_get_parameter_desc(&compiler
->base_effect
, parameter
, desc
);
3973 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler
*iface
,
3974 D3DXHANDLE technique
, D3DXTECHNIQUE_DESC
*desc
)
3976 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3978 TRACE("iface %p, technique %p, desc %p.\n", iface
, technique
, desc
);
3980 return d3dx9_base_effect_get_technique_desc(&compiler
->base_effect
, technique
, desc
);
3983 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler
*iface
,
3984 D3DXHANDLE pass
, D3DXPASS_DESC
*desc
)
3986 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3988 TRACE("iface %p, pass %p, desc %p.\n", iface
, pass
, desc
);
3990 return d3dx9_base_effect_get_pass_desc(&compiler
->base_effect
, pass
, desc
);
3993 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler
*iface
,
3994 D3DXHANDLE shader
, D3DXFUNCTION_DESC
*desc
)
3996 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
3998 TRACE("iface %p, shader %p, desc %p.\n", iface
, shader
, desc
);
4000 return d3dx9_base_effect_get_function_desc(&compiler
->base_effect
, shader
, desc
);
4003 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler
*iface
,
4004 D3DXHANDLE parameter
, UINT index
)
4006 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4008 TRACE("iface %p, parameter %p, index %u.\n", iface
, parameter
, index
);
4010 return d3dx9_base_effect_get_parameter(&compiler
->base_effect
, parameter
, index
);
4013 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler
*iface
,
4014 D3DXHANDLE parameter
, const char *name
)
4016 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4018 TRACE("iface %p, parameter %p, name %s.\n", iface
, parameter
, debugstr_a(name
));
4020 return d3dx9_base_effect_get_parameter_by_name(&compiler
->base_effect
, parameter
, name
);
4023 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler
*iface
,
4024 D3DXHANDLE parameter
, const char *semantic
)
4026 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4028 TRACE("iface %p, parameter %p, semantic %s.\n", iface
, parameter
, debugstr_a(semantic
));
4030 return d3dx9_base_effect_get_parameter_by_semantic(&compiler
->base_effect
, parameter
, semantic
);
4033 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler
*iface
,
4034 D3DXHANDLE parameter
, UINT index
)
4036 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4038 TRACE("iface %p, parameter %p, index %u.\n", iface
, parameter
, index
);
4040 return d3dx9_base_effect_get_parameter_element(&compiler
->base_effect
, parameter
, index
);
4043 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler
*iface
, UINT index
)
4045 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4047 TRACE("iface %p, index %u.\n", iface
, index
);
4049 return d3dx9_base_effect_get_technique(&compiler
->base_effect
, index
);
4052 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler
*iface
, const char *name
)
4054 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4056 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
4058 return d3dx9_base_effect_get_technique_by_name(&compiler
->base_effect
, name
);
4061 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler
*iface
, D3DXHANDLE technique
, UINT index
)
4063 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4065 TRACE("iface %p, technique %p, index %u.\n", iface
, technique
, index
);
4067 return d3dx9_base_effect_get_pass(&compiler
->base_effect
, technique
, index
);
4070 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler
*iface
,
4071 D3DXHANDLE technique
, const char *name
)
4073 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4075 TRACE("iface %p, technique %p, name %s.\n", iface
, technique
, debugstr_a(name
));
4077 return d3dx9_base_effect_get_pass_by_name(&compiler
->base_effect
, technique
, name
);
4080 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler
*iface
, UINT index
)
4082 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4084 TRACE("iface %p, index %u.\n", iface
, index
);
4086 return d3dx9_base_effect_get_function(&compiler
->base_effect
, index
);
4089 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler
*iface
, const char *name
)
4091 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4093 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
4095 return d3dx9_base_effect_get_function_by_name(&compiler
->base_effect
, name
);
4098 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler
*iface
,
4099 D3DXHANDLE object
, UINT index
)
4101 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4103 TRACE("iface %p, object %p, index %u.\n", iface
, object
, index
);
4105 return d3dx9_base_effect_get_annotation(&compiler
->base_effect
, object
, index
);
4108 static D3DXHANDLE WINAPI
ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler
*iface
,
4109 D3DXHANDLE object
, const char *name
)
4111 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4113 TRACE("iface %p, object %p, name %s.\n", iface
, object
, debugstr_a(name
));
4115 return d3dx9_base_effect_get_annotation_by_name(&compiler
->base_effect
, object
, name
);
4118 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler
*iface
,
4119 D3DXHANDLE parameter
, const void *data
, UINT bytes
)
4121 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4123 TRACE("iface %p, parameter %p, data %p, bytes %u.\n", iface
, parameter
, data
, bytes
);
4125 return d3dx9_base_effect_set_value(&compiler
->base_effect
, parameter
, data
, bytes
);
4128 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler
*iface
,
4129 D3DXHANDLE parameter
, void *data
, UINT bytes
)
4131 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4133 TRACE("iface %p, parameter %p, data %p, bytes %u.\n", iface
, parameter
, data
, bytes
);
4135 return d3dx9_base_effect_get_value(&compiler
->base_effect
, parameter
, data
, bytes
);
4138 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL b
)
4140 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4142 TRACE("iface %p, parameter %p, b %#x.\n", iface
, parameter
, b
);
4144 return d3dx9_base_effect_set_bool(&compiler
->base_effect
, parameter
, b
);
4147 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL
*b
)
4149 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4151 TRACE("iface %p, parameter %p, b %p.\n", iface
, parameter
, b
);
4153 return d3dx9_base_effect_get_bool(&compiler
->base_effect
, parameter
, b
);
4156 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler
*iface
,
4157 D3DXHANDLE parameter
, const BOOL
*b
, UINT count
)
4159 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4161 TRACE("iface %p, parameter %p, b %p, count %u.\n", iface
, parameter
, b
, count
);
4163 return d3dx9_base_effect_set_bool_array(&compiler
->base_effect
, parameter
, b
, count
);
4166 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler
*iface
,
4167 D3DXHANDLE parameter
, BOOL
*b
, UINT count
)
4169 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4171 TRACE("iface %p, parameter %p, b %p, count %u.\n", iface
, parameter
, b
, count
);
4173 return d3dx9_base_effect_get_bool_array(&compiler
->base_effect
, parameter
, b
, count
);
4176 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, INT n
)
4178 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4180 TRACE("iface %p, parameter %p, n %d.\n", iface
, parameter
, n
);
4182 return d3dx9_base_effect_set_int(&compiler
->base_effect
, parameter
, n
);
4185 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, INT
*n
)
4187 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4189 TRACE("iface %p, parameter %p, n %p.\n", iface
, parameter
, n
);
4191 return d3dx9_base_effect_get_int(&compiler
->base_effect
, parameter
, n
);
4194 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler
*iface
,
4195 D3DXHANDLE parameter
, const INT
*n
, UINT count
)
4197 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4199 TRACE("iface %p, parameter %p, n %p, count %u.\n", iface
, parameter
, n
, count
);
4201 return d3dx9_base_effect_set_int_array(&compiler
->base_effect
, parameter
, n
, count
);
4204 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler
*iface
,
4205 D3DXHANDLE parameter
, INT
*n
, UINT count
)
4207 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4209 TRACE("iface %p, parameter %p, n %p, count %u.\n", iface
, parameter
, n
, count
);
4211 return d3dx9_base_effect_get_int_array(&compiler
->base_effect
, parameter
, n
, count
);
4214 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, float f
)
4216 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4218 TRACE("iface %p, parameter %p, f %.8e.\n", iface
, parameter
, f
);
4220 return d3dx9_base_effect_set_float(&compiler
->base_effect
, parameter
, f
);
4223 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, float *f
)
4225 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4227 TRACE("iface %p, parameter %p, f %p.\n", iface
, parameter
, f
);
4229 return d3dx9_base_effect_get_float(&compiler
->base_effect
, parameter
, f
);
4232 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler
*iface
,
4233 D3DXHANDLE parameter
, const float *f
, UINT count
)
4235 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4237 TRACE("iface %p, parameter %p, f %p, count %u.\n", iface
, parameter
, f
, count
);
4239 return d3dx9_base_effect_set_float_array(&compiler
->base_effect
, parameter
, f
, count
);
4242 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler
*iface
,
4243 D3DXHANDLE parameter
, float *f
, UINT count
)
4245 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4247 TRACE("iface %p, parameter %p, f %p, count %u.\n", iface
, parameter
, f
, count
);
4249 return d3dx9_base_effect_get_float_array(&compiler
->base_effect
, parameter
, f
, count
);
4252 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler
*iface
,
4253 D3DXHANDLE parameter
, const D3DXVECTOR4
*vector
)
4255 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4257 TRACE("iface %p, parameter %p, vector %p.\n", iface
, parameter
, vector
);
4259 return d3dx9_base_effect_set_vector(&compiler
->base_effect
, parameter
, vector
);
4262 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler
*iface
,
4263 D3DXHANDLE parameter
, D3DXVECTOR4
*vector
)
4265 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4267 TRACE("iface %p, parameter %p, vector %p.\n", iface
, parameter
, vector
);
4269 return d3dx9_base_effect_get_vector(&compiler
->base_effect
, parameter
, vector
);
4272 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler
*iface
,
4273 D3DXHANDLE parameter
, const D3DXVECTOR4
*vector
, UINT count
)
4275 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4277 TRACE("iface %p, parameter %p, vector %p, count %u.\n", iface
, parameter
, vector
, count
);
4279 return d3dx9_base_effect_set_vector_array(&compiler
->base_effect
, parameter
, vector
, count
);
4282 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler
*iface
,
4283 D3DXHANDLE parameter
, D3DXVECTOR4
*vector
, UINT count
)
4285 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4287 TRACE("iface %p, parameter %p, vector %p, count %u.\n", iface
, parameter
, vector
, count
);
4289 return d3dx9_base_effect_get_vector_array(&compiler
->base_effect
, parameter
, vector
, count
);
4292 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler
*iface
,
4293 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
)
4295 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4297 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
4299 return d3dx9_base_effect_set_matrix(&compiler
->base_effect
, parameter
, matrix
);
4302 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler
*iface
,
4303 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
4305 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4307 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
4309 return d3dx9_base_effect_get_matrix(&compiler
->base_effect
, parameter
, matrix
);
4312 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler
*iface
,
4313 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
, UINT count
)
4315 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4317 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
4319 return d3dx9_base_effect_set_matrix_array(&compiler
->base_effect
, parameter
, matrix
, count
);
4322 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler
*iface
,
4323 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
4325 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4327 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
4329 return d3dx9_base_effect_get_matrix_array(&compiler
->base_effect
, parameter
, matrix
, count
);
4332 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler
*iface
,
4333 D3DXHANDLE parameter
, const D3DXMATRIX
**matrix
, UINT count
)
4335 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4337 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
4339 return d3dx9_base_effect_set_matrix_pointer_array(&compiler
->base_effect
, parameter
, matrix
, count
);
4342 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler
*iface
,
4343 D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
4345 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4347 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
4349 return d3dx9_base_effect_get_matrix_pointer_array(&compiler
->base_effect
, parameter
, matrix
, count
);
4352 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler
*iface
,
4353 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
)
4355 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4357 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
4359 return d3dx9_base_effect_set_matrix_transpose(&compiler
->base_effect
, parameter
, matrix
);
4362 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler
*iface
,
4363 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
)
4365 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4367 TRACE("iface %p, parameter %p, matrix %p.\n", iface
, parameter
, matrix
);
4369 return d3dx9_base_effect_get_matrix_transpose(&compiler
->base_effect
, parameter
, matrix
);
4372 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler
*iface
,
4373 D3DXHANDLE parameter
, const D3DXMATRIX
*matrix
, UINT count
)
4375 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4377 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
4379 return d3dx9_base_effect_set_matrix_transpose_array(&compiler
->base_effect
, parameter
, matrix
, count
);
4382 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler
*iface
,
4383 D3DXHANDLE parameter
, D3DXMATRIX
*matrix
, UINT count
)
4385 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4387 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
4389 return d3dx9_base_effect_get_matrix_transpose_array(&compiler
->base_effect
, parameter
, matrix
, count
);
4392 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler
*iface
,
4393 D3DXHANDLE parameter
, const D3DXMATRIX
**matrix
, UINT count
)
4395 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4397 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
4399 return d3dx9_base_effect_set_matrix_transpose_pointer_array(&compiler
->base_effect
, parameter
, matrix
, count
);
4402 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler
*iface
,
4403 D3DXHANDLE parameter
, D3DXMATRIX
**matrix
, UINT count
)
4405 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4407 TRACE("iface %p, parameter %p, matrix %p, count %u.\n", iface
, parameter
, matrix
, count
);
4409 return d3dx9_base_effect_get_matrix_transpose_pointer_array(&compiler
->base_effect
, parameter
, matrix
, count
);
4412 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler
*iface
,
4413 D3DXHANDLE parameter
, const char *string
)
4415 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4417 TRACE("iface %p, parameter %p, string %s.\n", iface
, parameter
, debugstr_a(string
));
4419 return d3dx9_base_effect_set_string(&compiler
->base_effect
, parameter
, string
);
4422 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler
*iface
,
4423 D3DXHANDLE parameter
, const char **string
)
4425 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4427 TRACE("iface %p, parameter %p, string %p.\n", iface
, parameter
, string
);
4429 return d3dx9_base_effect_get_string(&compiler
->base_effect
, parameter
, string
);
4432 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetTexture(struct ID3DXEffectCompiler
*iface
,
4433 D3DXHANDLE parameter
, struct IDirect3DBaseTexture9
*texture
)
4435 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4437 TRACE("iface %p, parameter %p, texture %p.\n", iface
, parameter
, texture
);
4439 return d3dx9_base_effect_set_texture(&compiler
->base_effect
, parameter
, texture
);
4442 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetTexture(struct ID3DXEffectCompiler
*iface
,
4443 D3DXHANDLE parameter
, struct IDirect3DBaseTexture9
**texture
)
4445 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4447 TRACE("iface %p, parameter %p, texture %p.\n", iface
, parameter
, texture
);
4449 return d3dx9_base_effect_get_texture(&compiler
->base_effect
, parameter
, texture
);
4452 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler
*iface
,
4453 D3DXHANDLE parameter
, struct IDirect3DPixelShader9
**shader
)
4455 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4457 TRACE("iface %p, parameter %p, shader %p.\n", iface
, parameter
, shader
);
4459 return d3dx9_base_effect_get_pixel_shader(&compiler
->base_effect
, parameter
, shader
);
4462 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetVertexShader(struct ID3DXEffectCompiler
*iface
,
4463 D3DXHANDLE parameter
, struct IDirect3DVertexShader9
**shader
)
4465 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4467 TRACE("iface %p, parameter %p, shader %p.\n", iface
, parameter
, shader
);
4469 return d3dx9_base_effect_get_vertex_shader(&compiler
->base_effect
, parameter
, shader
);
4472 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler
*iface
,
4473 D3DXHANDLE parameter
, UINT start
, UINT end
)
4475 struct ID3DXEffectCompilerImpl
*compiler
= impl_from_ID3DXEffectCompiler(iface
);
4477 TRACE("iface %p, parameter %p, start %u, end %u.\n", iface
, parameter
, start
, end
);
4479 return d3dx9_base_effect_set_array_range(&compiler
->base_effect
, parameter
, start
, end
);
4482 /*** ID3DXEffectCompiler methods ***/
4483 static HRESULT WINAPI
ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL literal
)
4485 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4487 FIXME("iface %p, parameter %p, literal %u\n", This
, parameter
, literal
);
4492 static HRESULT WINAPI
ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler
*iface
, D3DXHANDLE parameter
, BOOL
*literal
)
4494 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4496 FIXME("iface %p, parameter %p, literal %p\n", This
, parameter
, literal
);
4501 static HRESULT WINAPI
ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler
*iface
, DWORD flags
,
4502 ID3DXBuffer
**effect
, ID3DXBuffer
**error_msgs
)
4504 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4506 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This
, flags
, effect
, error_msgs
);
4511 static HRESULT WINAPI
ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler
*iface
, D3DXHANDLE function
,
4512 const char *target
, DWORD flags
, ID3DXBuffer
**shader
, ID3DXBuffer
**error_msgs
,
4513 ID3DXConstantTable
**constant_table
)
4515 struct ID3DXEffectCompilerImpl
*This
= impl_from_ID3DXEffectCompiler(iface
);
4517 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
4518 This
, function
, target
, flags
, shader
, error_msgs
, constant_table
);
4523 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl
=
4525 /*** IUnknown methods ***/
4526 ID3DXEffectCompilerImpl_QueryInterface
,
4527 ID3DXEffectCompilerImpl_AddRef
,
4528 ID3DXEffectCompilerImpl_Release
,
4529 /*** ID3DXBaseEffect methods ***/
4530 ID3DXEffectCompilerImpl_GetDesc
,
4531 ID3DXEffectCompilerImpl_GetParameterDesc
,
4532 ID3DXEffectCompilerImpl_GetTechniqueDesc
,
4533 ID3DXEffectCompilerImpl_GetPassDesc
,
4534 ID3DXEffectCompilerImpl_GetFunctionDesc
,
4535 ID3DXEffectCompilerImpl_GetParameter
,
4536 ID3DXEffectCompilerImpl_GetParameterByName
,
4537 ID3DXEffectCompilerImpl_GetParameterBySemantic
,
4538 ID3DXEffectCompilerImpl_GetParameterElement
,
4539 ID3DXEffectCompilerImpl_GetTechnique
,
4540 ID3DXEffectCompilerImpl_GetTechniqueByName
,
4541 ID3DXEffectCompilerImpl_GetPass
,
4542 ID3DXEffectCompilerImpl_GetPassByName
,
4543 ID3DXEffectCompilerImpl_GetFunction
,
4544 ID3DXEffectCompilerImpl_GetFunctionByName
,
4545 ID3DXEffectCompilerImpl_GetAnnotation
,
4546 ID3DXEffectCompilerImpl_GetAnnotationByName
,
4547 ID3DXEffectCompilerImpl_SetValue
,
4548 ID3DXEffectCompilerImpl_GetValue
,
4549 ID3DXEffectCompilerImpl_SetBool
,
4550 ID3DXEffectCompilerImpl_GetBool
,
4551 ID3DXEffectCompilerImpl_SetBoolArray
,
4552 ID3DXEffectCompilerImpl_GetBoolArray
,
4553 ID3DXEffectCompilerImpl_SetInt
,
4554 ID3DXEffectCompilerImpl_GetInt
,
4555 ID3DXEffectCompilerImpl_SetIntArray
,
4556 ID3DXEffectCompilerImpl_GetIntArray
,
4557 ID3DXEffectCompilerImpl_SetFloat
,
4558 ID3DXEffectCompilerImpl_GetFloat
,
4559 ID3DXEffectCompilerImpl_SetFloatArray
,
4560 ID3DXEffectCompilerImpl_GetFloatArray
,
4561 ID3DXEffectCompilerImpl_SetVector
,
4562 ID3DXEffectCompilerImpl_GetVector
,
4563 ID3DXEffectCompilerImpl_SetVectorArray
,
4564 ID3DXEffectCompilerImpl_GetVectorArray
,
4565 ID3DXEffectCompilerImpl_SetMatrix
,
4566 ID3DXEffectCompilerImpl_GetMatrix
,
4567 ID3DXEffectCompilerImpl_SetMatrixArray
,
4568 ID3DXEffectCompilerImpl_GetMatrixArray
,
4569 ID3DXEffectCompilerImpl_SetMatrixPointerArray
,
4570 ID3DXEffectCompilerImpl_GetMatrixPointerArray
,
4571 ID3DXEffectCompilerImpl_SetMatrixTranspose
,
4572 ID3DXEffectCompilerImpl_GetMatrixTranspose
,
4573 ID3DXEffectCompilerImpl_SetMatrixTransposeArray
,
4574 ID3DXEffectCompilerImpl_GetMatrixTransposeArray
,
4575 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray
,
4576 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray
,
4577 ID3DXEffectCompilerImpl_SetString
,
4578 ID3DXEffectCompilerImpl_GetString
,
4579 ID3DXEffectCompilerImpl_SetTexture
,
4580 ID3DXEffectCompilerImpl_GetTexture
,
4581 ID3DXEffectCompilerImpl_GetPixelShader
,
4582 ID3DXEffectCompilerImpl_GetVertexShader
,
4583 ID3DXEffectCompilerImpl_SetArrayRange
,
4584 /*** ID3DXEffectCompiler methods ***/
4585 ID3DXEffectCompilerImpl_SetLiteral
,
4586 ID3DXEffectCompilerImpl_GetLiteral
,
4587 ID3DXEffectCompilerImpl_CompileEffect
,
4588 ID3DXEffectCompilerImpl_CompileShader
,
4591 static HRESULT
d3dx9_parse_sampler(struct d3dx9_base_effect
*base
, struct d3dx_sampler
*sampler
,
4592 const char *data
, const char **ptr
, struct d3dx_object
*objects
)
4597 read_dword(ptr
, &sampler
->state_count
);
4598 TRACE("Count: %u\n", sampler
->state_count
);
4600 sampler
->states
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*sampler
->states
) * sampler
->state_count
);
4601 if (!sampler
->states
)
4603 ERR("Out of memory\n");
4604 return E_OUTOFMEMORY
;
4607 for (i
= 0; i
< sampler
->state_count
; ++i
)
4609 hr
= d3dx9_parse_state(base
, &sampler
->states
[i
], data
, ptr
, objects
);
4612 WARN("Failed to parse state %u\n", i
);
4621 for (i
= 0; i
< sampler
->state_count
; ++i
)
4623 free_state(&sampler
->states
[i
]);
4625 HeapFree(GetProcessHeap(), 0, sampler
->states
);
4626 sampler
->states
= NULL
;
4631 static HRESULT
d3dx9_parse_value(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*param
,
4632 void *value
, const char *data
, const char **ptr
, struct d3dx_object
*objects
)
4638 if (param
->element_count
)
4640 param
->data
= value
;
4642 for (i
= 0; i
< param
->element_count
; ++i
)
4644 struct d3dx_parameter
*member
= ¶m
->members
[i
];
4646 hr
= d3dx9_parse_value(base
, member
, value
? (char *)value
+ old_size
: NULL
, data
, ptr
, objects
);
4649 WARN("Failed to parse value %u\n", i
);
4653 old_size
+= member
->bytes
;
4659 switch(param
->class)
4663 case D3DXPC_MATRIX_ROWS
:
4664 case D3DXPC_MATRIX_COLUMNS
:
4665 param
->data
= value
;
4669 param
->data
= value
;
4671 for (i
= 0; i
< param
->member_count
; ++i
)
4673 struct d3dx_parameter
*member
= ¶m
->members
[i
];
4675 hr
= d3dx9_parse_value(base
, member
, (char *)value
+ old_size
, data
, ptr
, objects
);
4678 WARN("Failed to parse value %u\n", i
);
4682 old_size
+= member
->bytes
;
4687 switch (param
->type
)
4690 case D3DXPT_TEXTURE
:
4691 case D3DXPT_TEXTURE1D
:
4692 case D3DXPT_TEXTURE2D
:
4693 case D3DXPT_TEXTURE3D
:
4694 case D3DXPT_TEXTURECUBE
:
4695 case D3DXPT_PIXELSHADER
:
4696 case D3DXPT_VERTEXSHADER
:
4697 read_dword(ptr
, ¶m
->object_id
);
4698 TRACE("Id: %u\n", param
->object_id
);
4699 objects
[param
->object_id
].param
= param
;
4700 param
->data
= value
;
4703 case D3DXPT_SAMPLER
:
4704 case D3DXPT_SAMPLER1D
:
4705 case D3DXPT_SAMPLER2D
:
4706 case D3DXPT_SAMPLER3D
:
4707 case D3DXPT_SAMPLERCUBE
:
4709 struct d3dx_sampler
*sampler
;
4711 sampler
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*sampler
));
4713 return E_OUTOFMEMORY
;
4715 hr
= d3dx9_parse_sampler(base
, sampler
, data
, ptr
, objects
);
4718 HeapFree(GetProcessHeap(), 0, sampler
);
4719 WARN("Failed to parse sampler\n");
4723 param
->data
= sampler
;
4728 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
4734 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
4741 static HRESULT
d3dx9_parse_init_value(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*param
,
4742 const char *data
, const char *ptr
, struct d3dx_object
*objects
)
4744 UINT size
= param
->bytes
;
4748 TRACE("param size: %u\n", size
);
4752 value
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
4755 ERR("Failed to allocate data memory.\n");
4756 return E_OUTOFMEMORY
;
4759 switch(param
->class)
4766 case D3DXPC_MATRIX_ROWS
:
4767 case D3DXPC_MATRIX_COLUMNS
:
4769 TRACE("Data: %s.\n", debugstr_an(ptr
, size
));
4770 memcpy(value
, ptr
, size
);
4774 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
4779 hr
= d3dx9_parse_value(base
, param
, value
, data
, &ptr
, objects
);
4782 WARN("Failed to parse value\n");
4783 HeapFree(GetProcessHeap(), 0, value
);
4790 static HRESULT
d3dx9_parse_name(char **name
, const char *ptr
)
4794 read_dword(&ptr
, &size
);
4795 TRACE("Name size: %#x\n", size
);
4802 *name
= HeapAlloc(GetProcessHeap(), 0, size
);
4805 ERR("Failed to allocate name memory.\n");
4806 return E_OUTOFMEMORY
;
4809 TRACE("Name: %s.\n", debugstr_an(ptr
, size
));
4810 memcpy(*name
, ptr
, size
);
4815 static HRESULT
d3dx9_copy_data(struct d3dx9_base_effect
*base
, unsigned int object_id
, const char **ptr
)
4817 struct d3dx_object
*object
= &base
->objects
[object_id
];
4819 if (object
->size
|| object
->data
)
4822 FIXME("Overwriting object id %u!\n", object_id
);
4824 TRACE("Overwriting object id 0.\n");
4826 HeapFree(GetProcessHeap(), 0, object
->data
);
4827 object
->data
= NULL
;
4830 read_dword(ptr
, &object
->size
);
4831 TRACE("Data size: %#x.\n", object
->size
);
4836 object
->data
= HeapAlloc(GetProcessHeap(), 0, object
->size
);
4839 ERR("Failed to allocate object memory.\n");
4840 return E_OUTOFMEMORY
;
4843 TRACE("Data: %s.\n", debugstr_an(*ptr
, object
->size
));
4844 memcpy(object
->data
, *ptr
, object
->size
);
4846 *ptr
+= ((object
->size
+ 3) & ~3);
4851 static void add_param_to_table(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*param
)
4853 struct param_table
*table
= &base
->param_table
;
4855 if (table
->count
>= table
->size
)
4857 unsigned int new_size
;
4858 struct d3dx_parameter
**new_alloc
;
4862 new_size
= INITIAL_PARAM_TABLE_SIZE
;
4863 new_alloc
= HeapAlloc(GetProcessHeap(), 0, sizeof(*table
->table
) * new_size
);
4866 ERR("Out of memory.\n");
4872 new_size
= table
->size
* 2;
4873 new_alloc
= HeapReAlloc(GetProcessHeap(), 0, table
->table
, sizeof(*table
->table
) * new_size
);
4876 ERR("Out of memory.\n");
4880 table
->table
= new_alloc
;
4881 table
->size
= new_size
;
4884 table
->table
[table
->count
++] = param
;
4887 static void sync_param_handles(struct d3dx9_base_effect
*base
)
4889 struct param_table
*table
= &base
->param_table
;
4890 struct d3dx_parameter
**new_alloc
;
4895 new_alloc
= HeapReAlloc(GetProcessHeap(), 0, table
->table
, sizeof(*table
->table
) * table
->count
);
4897 table
->table
= new_alloc
;
4899 ERR("Out of memory.\n");
4902 for (i
= 0; i
< table
->count
; ++i
)
4903 table
->table
[i
]->handle
= (D3DXHANDLE
)&table
->table
[i
];
4906 static HRESULT
d3dx9_parse_effect_typedef(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*param
,
4907 const char *data
, const char **ptr
, struct d3dx_parameter
*parent
, UINT flags
)
4913 param
->flags
= flags
;
4917 read_dword(ptr
, (DWORD
*)¶m
->type
);
4918 TRACE("Type: %s\n", debug_d3dxparameter_type(param
->type
));
4920 read_dword(ptr
, (DWORD
*)¶m
->class);
4921 TRACE("Class: %s\n", debug_d3dxparameter_class(param
->class));
4923 read_dword(ptr
, &offset
);
4924 TRACE("Type name offset: %#x\n", offset
);
4925 hr
= d3dx9_parse_name(¶m
->name
, data
+ offset
);
4928 WARN("Failed to parse name\n");
4932 read_dword(ptr
, &offset
);
4933 TRACE("Type semantic offset: %#x\n", offset
);
4934 hr
= d3dx9_parse_name(¶m
->semantic
, data
+ offset
);
4937 WARN("Failed to parse semantic\n");
4941 read_dword(ptr
, ¶m
->element_count
);
4942 TRACE("Elements: %u\n", param
->element_count
);
4944 switch (param
->class)
4947 read_dword(ptr
, ¶m
->columns
);
4948 TRACE("Columns: %u\n", param
->columns
);
4950 read_dword(ptr
, ¶m
->rows
);
4951 TRACE("Rows: %u\n", param
->rows
);
4953 /* sizeof(DWORD) * rows * columns */
4954 param
->bytes
= 4 * param
->rows
* param
->columns
;
4958 case D3DXPC_MATRIX_ROWS
:
4959 case D3DXPC_MATRIX_COLUMNS
:
4960 read_dword(ptr
, ¶m
->rows
);
4961 TRACE("Rows: %u\n", param
->rows
);
4963 read_dword(ptr
, ¶m
->columns
);
4964 TRACE("Columns: %u\n", param
->columns
);
4966 /* sizeof(DWORD) * rows * columns */
4967 param
->bytes
= 4 * param
->rows
* param
->columns
;
4971 read_dword(ptr
, ¶m
->member_count
);
4972 TRACE("Members: %u\n", param
->member_count
);
4976 switch (param
->type
)
4979 case D3DXPT_PIXELSHADER
:
4980 case D3DXPT_VERTEXSHADER
:
4981 case D3DXPT_TEXTURE
:
4982 case D3DXPT_TEXTURE1D
:
4983 case D3DXPT_TEXTURE2D
:
4984 case D3DXPT_TEXTURE3D
:
4985 case D3DXPT_TEXTURECUBE
:
4986 param
->bytes
= sizeof(void *);
4989 case D3DXPT_SAMPLER
:
4990 case D3DXPT_SAMPLER1D
:
4991 case D3DXPT_SAMPLER2D
:
4992 case D3DXPT_SAMPLER3D
:
4993 case D3DXPT_SAMPLERCUBE
:
4998 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
5004 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param
->class));
5011 param
->type
= parent
->type
;
5012 param
->class = parent
->class;
5013 param
->name
= parent
->name
;
5014 param
->semantic
= parent
->semantic
;
5015 param
->element_count
= 0;
5016 param
->annotation_count
= 0;
5017 param
->member_count
= parent
->member_count
;
5018 param
->bytes
= parent
->bytes
;
5019 param
->rows
= parent
->rows
;
5020 param
->columns
= parent
->columns
;
5023 if (param
->element_count
)
5025 unsigned int param_bytes
= 0;
5026 const char *save_ptr
= *ptr
;
5028 param
->members
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*param
->members
) * param
->element_count
);
5029 if (!param
->members
)
5031 ERR("Out of memory\n");
5036 for (i
= 0; i
< param
->element_count
; ++i
)
5040 add_param_to_table(base
, ¶m
->members
[i
]);
5041 hr
= d3dx9_parse_effect_typedef(base
, ¶m
->members
[i
], data
, ptr
, param
, flags
);
5044 WARN("Failed to parse member %u\n", i
);
5048 param_bytes
+= param
->members
[i
].bytes
;
5051 param
->bytes
= param_bytes
;
5053 else if (param
->member_count
)
5055 param
->members
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*param
->members
) * param
->member_count
);
5056 if (!param
->members
)
5058 ERR("Out of memory\n");
5063 for (i
= 0; i
< param
->member_count
; ++i
)
5065 add_param_to_table(base
, ¶m
->members
[i
]);
5066 hr
= d3dx9_parse_effect_typedef(base
, ¶m
->members
[i
], data
, ptr
, NULL
, flags
);
5069 WARN("Failed to parse member %u\n", i
);
5073 param
->bytes
+= param
->members
[i
].bytes
;
5082 unsigned int count
= param
->element_count
? param
->element_count
: param
->member_count
;
5084 for (i
= 0; i
< count
; ++i
)
5085 free_parameter(¶m
->members
[i
], param
->element_count
!= 0, TRUE
);
5086 HeapFree(GetProcessHeap(), 0, param
->members
);
5087 param
->members
= NULL
;
5092 HeapFree(GetProcessHeap(), 0, param
->name
);
5093 HeapFree(GetProcessHeap(), 0, param
->semantic
);
5096 param
->semantic
= NULL
;
5101 static HRESULT
d3dx9_parse_effect_annotation(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*anno
,
5102 const char *data
, const char **ptr
, struct d3dx_object
*objects
)
5108 anno
->flags
= D3DX_PARAMETER_ANNOTATION
;
5110 read_dword(ptr
, &offset
);
5111 TRACE("Typedef offset: %#x\n", offset
);
5112 ptr2
= data
+ offset
;
5113 hr
= d3dx9_parse_effect_typedef(base
, anno
, data
, &ptr2
, NULL
, D3DX_PARAMETER_ANNOTATION
);
5116 WARN("Failed to parse type definition\n");
5120 read_dword(ptr
, &offset
);
5121 TRACE("Value offset: %#x\n", offset
);
5122 hr
= d3dx9_parse_init_value(base
, anno
, data
, data
+ offset
, objects
);
5125 WARN("Failed to parse value\n");
5132 static HRESULT
d3dx9_parse_state(struct d3dx9_base_effect
*base
, struct d3dx_state
*state
,
5133 const char *data
, const char **ptr
, struct d3dx_object
*objects
)
5139 state
->type
= ST_CONSTANT
;
5141 read_dword(ptr
, &state
->operation
);
5142 TRACE("Operation: %#x (%s)\n", state
->operation
, state_table
[state
->operation
].name
);
5144 read_dword(ptr
, &state
->index
);
5145 TRACE("Index: %#x\n", state
->index
);
5147 read_dword(ptr
, &offset
);
5148 TRACE("Typedef offset: %#x\n", offset
);
5149 ptr2
= data
+ offset
;
5150 hr
= d3dx9_parse_effect_typedef(base
, &state
->parameter
, data
, &ptr2
, NULL
, 0);
5153 WARN("Failed to parse type definition\n");
5157 read_dword(ptr
, &offset
);
5158 TRACE("Value offset: %#x\n", offset
);
5159 hr
= d3dx9_parse_init_value(base
, &state
->parameter
, data
, data
+ offset
, objects
);
5162 WARN("Failed to parse value\n");
5170 free_parameter(&state
->parameter
, FALSE
, FALSE
);
5175 static HRESULT
d3dx9_parse_effect_parameter(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*param
,
5176 const char *data
, const char **ptr
, struct d3dx_object
*objects
)
5183 read_dword(ptr
, &offset
);
5184 TRACE("Typedef offset: %#x\n", offset
);
5185 ptr2
= data
+ offset
;
5187 read_dword(ptr
, &offset
);
5188 TRACE("Value offset: %#x\n", offset
);
5190 read_dword(ptr
, ¶m
->flags
);
5191 TRACE("Flags: %#x\n", param
->flags
);
5193 read_dword(ptr
, ¶m
->annotation_count
);
5194 TRACE("Annotation count: %u\n", param
->annotation_count
);
5196 hr
= d3dx9_parse_effect_typedef(base
, param
, data
, &ptr2
, NULL
, param
->flags
);
5199 WARN("Failed to parse type definition\n");
5203 hr
= d3dx9_parse_init_value(base
, param
, data
, data
+ offset
, objects
);
5206 WARN("Failed to parse value\n");
5210 if (param
->annotation_count
)
5212 param
->annotations
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
5213 sizeof(*param
->annotations
) * param
->annotation_count
);
5214 if (!param
->annotations
)
5216 ERR("Out of memory\n");
5221 for (i
= 0; i
< param
->annotation_count
; ++i
)
5223 add_param_to_table(base
, ¶m
->annotations
[i
]);
5224 hr
= d3dx9_parse_effect_annotation(base
, ¶m
->annotations
[i
], data
, ptr
, objects
);
5227 WARN("Failed to parse annotation\n");
5237 if (param
->annotations
)
5239 for (i
= 0; i
< param
->annotation_count
; ++i
)
5240 free_parameter(¶m
->annotations
[i
], FALSE
, FALSE
);
5241 HeapFree(GetProcessHeap(), 0, param
->annotations
);
5242 param
->annotations
= NULL
;
5248 static HRESULT
d3dx9_parse_effect_pass(struct d3dx9_base_effect
*base
, struct d3dx_pass
*pass
,
5249 const char *data
, const char **ptr
, struct d3dx_object
*objects
)
5254 struct d3dx_state
*states
= NULL
;
5257 read_dword(ptr
, &offset
);
5258 TRACE("Pass name offset: %#x\n", offset
);
5259 hr
= d3dx9_parse_name(&name
, data
+ offset
);
5262 WARN("Failed to parse name\n");
5266 read_dword(ptr
, &pass
->annotation_count
);
5267 TRACE("Annotation count: %u\n", pass
->annotation_count
);
5269 read_dword(ptr
, &pass
->state_count
);
5270 TRACE("State count: %u\n", pass
->state_count
);
5272 if (pass
->annotation_count
)
5274 pass
->annotations
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
5275 sizeof(*pass
->annotations
) * pass
->annotation_count
);
5276 if (!pass
->annotations
)
5278 ERR("Out of memory\n");
5283 for (i
= 0; i
< pass
->annotation_count
; ++i
)
5285 add_param_to_table(base
, &pass
->annotations
[i
]);
5286 hr
= d3dx9_parse_effect_annotation(base
, &pass
->annotations
[i
], data
, ptr
, objects
);
5289 WARN("Failed to parse annotation %u\n", i
);
5295 if (pass
->state_count
)
5297 states
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*states
) * pass
->state_count
);
5300 ERR("Out of memory\n");
5305 for (i
= 0; i
< pass
->state_count
; ++i
)
5307 hr
= d3dx9_parse_state(base
, &states
[i
], data
, ptr
, objects
);
5310 WARN("Failed to parse annotation %u\n", i
);
5317 pass
->states
= states
;
5323 if (pass
->annotations
)
5325 for (i
= 0; i
< pass
->annotation_count
; ++i
)
5326 free_parameter(&pass
->annotations
[i
], FALSE
, FALSE
);
5327 HeapFree(GetProcessHeap(), 0, pass
->annotations
);
5328 pass
->annotations
= NULL
;
5333 for (i
= 0; i
< pass
->state_count
; ++i
)
5335 free_state(&states
[i
]);
5337 HeapFree(GetProcessHeap(), 0, states
);
5340 HeapFree(GetProcessHeap(), 0, name
);
5345 static HRESULT
d3dx9_parse_effect_technique(struct d3dx9_base_effect
*base
, struct d3dx_technique
*technique
,
5346 const char *data
, const char **ptr
, struct d3dx_object
*objects
)
5353 read_dword(ptr
, &offset
);
5354 TRACE("Technique name offset: %#x\n", offset
);
5355 hr
= d3dx9_parse_name(&name
, data
+ offset
);
5358 WARN("Failed to parse name\n");
5362 read_dword(ptr
, &technique
->annotation_count
);
5363 TRACE("Annotation count: %u\n", technique
->annotation_count
);
5365 read_dword(ptr
, &technique
->pass_count
);
5366 TRACE("Pass count: %u\n", technique
->pass_count
);
5368 if (technique
->annotation_count
)
5370 technique
->annotations
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
5371 sizeof(*technique
->annotations
) * technique
->annotation_count
);
5372 if (!technique
->annotations
)
5374 ERR("Out of memory\n");
5379 for (i
= 0; i
< technique
->annotation_count
; ++i
)
5381 add_param_to_table(base
, &technique
->annotations
[i
]);
5382 hr
= d3dx9_parse_effect_annotation(base
, &technique
->annotations
[i
], data
, ptr
, objects
);
5385 WARN("Failed to parse annotation %u\n", i
);
5391 if (technique
->pass_count
)
5393 technique
->passes
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
5394 sizeof(*technique
->passes
) * technique
->pass_count
);
5395 if (!technique
->passes
)
5397 ERR("Out of memory\n");
5402 for (i
= 0; i
< technique
->pass_count
; ++i
)
5404 hr
= d3dx9_parse_effect_pass(base
, &technique
->passes
[i
], data
, ptr
, objects
);
5407 WARN("Failed to parse pass %u\n", i
);
5413 technique
->name
= name
;
5419 if (technique
->passes
)
5421 for (i
= 0; i
< technique
->pass_count
; ++i
)
5422 free_pass(&technique
->passes
[i
]);
5423 HeapFree(GetProcessHeap(), 0, technique
->passes
);
5424 technique
->passes
= NULL
;
5427 if (technique
->annotations
)
5429 for (i
= 0; i
< technique
->annotation_count
; ++i
)
5430 free_parameter(&technique
->annotations
[i
], FALSE
, FALSE
);
5431 HeapFree(GetProcessHeap(), 0, technique
->annotations
);
5432 technique
->annotations
= NULL
;
5435 HeapFree(GetProcessHeap(), 0, name
);
5440 static HRESULT
d3dx9_create_object(struct d3dx9_base_effect
*base
, struct d3dx_object
*object
)
5442 struct d3dx_parameter
*param
= object
->param
;
5443 struct IDirect3DDevice9
*device
= base
->effect
->device
;
5446 if (*(char **)param
->data
)
5447 ERR("Parameter data already allocated.\n");
5449 switch (param
->type
)
5452 *(char **)param
->data
= HeapAlloc(GetProcessHeap(), 0, object
->size
);
5453 if (!*(char **)param
->data
)
5455 ERR("Out of memory.\n");
5456 return E_OUTOFMEMORY
;
5458 memcpy(*(char **)param
->data
, object
->data
, object
->size
);
5460 case D3DXPT_VERTEXSHADER
:
5461 if (FAILED(hr
= IDirect3DDevice9_CreateVertexShader(device
, object
->data
,
5462 (IDirect3DVertexShader9
**)param
->data
)))
5464 WARN("Failed to create vertex shader.\n");
5468 case D3DXPT_PIXELSHADER
:
5469 if (FAILED(hr
= IDirect3DDevice9_CreatePixelShader(device
, object
->data
,
5470 (IDirect3DPixelShader9
**)param
->data
)))
5472 WARN("Failed to create pixel shader.\n");
5482 static HRESULT
d3dx9_parse_array_selector(struct d3dx9_base_effect
*base
, struct d3dx_parameter
*param
)
5485 struct d3dx_object
*object
= &base
->objects
[param
->object_id
];
5486 char *ptr
= object
->data
;
5489 TRACE("Parsing array entry selection state for parameter %p.\n", param
);
5491 string_size
= *(DWORD
*)ptr
;
5492 param
->referenced_param
= get_parameter_by_name(base
, NULL
, ptr
+ 4);
5493 if (param
->referenced_param
)
5495 TRACE("Mapping to parameter %s.\n", debugstr_a(param
->referenced_param
->name
));
5499 FIXME("Referenced parameter %s not found.\n", ptr
+ 4);
5500 return D3DXERR_INVALIDDATA
;
5502 TRACE("Unknown DWORD: 0x%.8x.\n", *(DWORD
*)(ptr
+ string_size
));
5504 if (string_size
% sizeof(DWORD
))
5505 FIXME("Unaligned string_size %u.\n", string_size
);
5506 d3dx_create_param_eval(base
, (DWORD
*)(ptr
+ string_size
) + 1, object
->size
- (string_size
+ sizeof(DWORD
)),
5507 D3DXPT_INT
, ¶m
->param_eval
);
5509 param
= param
->referenced_param
;
5510 if (param
->type
== D3DXPT_VERTEXSHADER
|| param
->type
== D3DXPT_PIXELSHADER
)
5514 for (i
= 0; i
< param
->element_count
; i
++)
5516 if (param
->members
[i
].type
!= param
->type
)
5518 FIXME("Unexpected member parameter type %u, expected %u.\n", param
->members
[i
].type
, param
->type
);
5519 return D3DXERR_INVALIDDATA
;
5521 if (!param
->members
[i
].param_eval
)
5523 TRACE("Creating preshader for object %u.\n", param
->members
[i
].object_id
);
5524 object
= &base
->objects
[param
->members
[i
].object_id
];
5525 d3dx_create_param_eval(base
, object
->data
, object
->size
, param
->type
, ¶m
->members
[i
].param_eval
);
5532 static HRESULT
d3dx9_parse_resource(struct d3dx9_base_effect
*base
, const char *data
, const char **ptr
)
5534 DWORD technique_index
;
5535 DWORD index
, state_index
, usage
, element_index
;
5536 struct d3dx_state
*state
;
5537 struct d3dx_parameter
*param
;
5538 struct d3dx_object
*object
;
5539 HRESULT hr
= E_FAIL
;
5541 read_dword(ptr
, &technique_index
);
5542 TRACE("technique_index: %u\n", technique_index
);
5544 read_dword(ptr
, &index
);
5545 TRACE("index: %u\n", index
);
5547 read_dword(ptr
, &element_index
);
5548 TRACE("element_index: %u\n", element_index
);
5550 read_dword(ptr
, &state_index
);
5551 TRACE("state_index: %u\n", state_index
);
5553 read_dword(ptr
, &usage
);
5554 TRACE("usage: %u\n", usage
);
5556 if (technique_index
== 0xffffffff)
5558 struct d3dx_parameter
*parameter
;
5559 struct d3dx_sampler
*sampler
;
5561 if (index
>= base
->parameter_count
)
5563 FIXME("Index out of bounds: index %u >= parameter_count %u\n", index
, base
->parameter_count
);
5567 parameter
= &base
->parameters
[index
];
5568 if (element_index
!= 0xffffffff)
5570 if (element_index
>= parameter
->element_count
&& parameter
->element_count
!= 0)
5572 FIXME("Index out of bounds: element_index %u >= element_count %u\n", element_index
, parameter
->element_count
);
5576 if (parameter
->element_count
!= 0) parameter
= ¶meter
->members
[element_index
];
5579 sampler
= parameter
->data
;
5580 if (state_index
>= sampler
->state_count
)
5582 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index
, sampler
->state_count
);
5586 state
= &sampler
->states
[state_index
];
5590 struct d3dx_technique
*technique
;
5591 struct d3dx_pass
*pass
;
5593 if (technique_index
>= base
->technique_count
)
5595 FIXME("Index out of bounds: technique_index %u >= technique_count %u\n", technique_index
, base
->technique_count
);
5599 technique
= &base
->techniques
[technique_index
];
5600 if (index
>= technique
->pass_count
)
5602 FIXME("Index out of bounds: index %u >= pass_count %u\n", index
, technique
->pass_count
);
5606 pass
= &technique
->passes
[index
];
5607 if (state_index
>= pass
->state_count
)
5609 FIXME("Index out of bounds: state_index %u >= state_count %u\n", state_index
, pass
->state_count
);
5613 state
= &pass
->states
[state_index
];
5616 TRACE("State operation %#x (%s).\n", state
->operation
, state_table
[state
->operation
].name
);
5617 param
= &state
->parameter
;
5618 TRACE("Using object id %u.\n", param
->object_id
);
5619 object
= &base
->objects
[param
->object_id
];
5621 TRACE("Usage %u: class %s, type %s.\n", usage
, debug_d3dxparameter_class(param
->class),
5622 debug_d3dxparameter_type(param
->type
));
5626 switch (param
->type
)
5628 case D3DXPT_VERTEXSHADER
:
5629 case D3DXPT_PIXELSHADER
:
5630 state
->type
= ST_CONSTANT
;
5631 if (FAILED(hr
= d3dx9_copy_data(base
, param
->object_id
, ptr
)))
5636 if (FAILED(hr
= d3dx9_create_object(base
, object
)))
5638 d3dx_create_param_eval(base
, object
->data
, object
->size
, param
->type
, ¶m
->param_eval
);
5646 state
->type
= ST_FXLC
;
5647 if (FAILED(hr
= d3dx9_copy_data(base
, param
->object_id
, ptr
)))
5649 d3dx_create_param_eval(base
, object
->data
, object
->size
, param
->type
, ¶m
->param_eval
);
5653 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param
->type
));
5659 state
->type
= ST_PARAMETER
;
5660 if (FAILED(hr
= d3dx9_copy_data(base
, param
->object_id
, ptr
)))
5663 TRACE("Looking for parameter %s.\n", debugstr_a(object
->data
));
5664 param
->referenced_param
= get_parameter_by_name(base
, NULL
, object
->data
);
5665 if (param
->referenced_param
)
5667 struct d3dx_parameter
*refpar
= param
->referenced_param
;
5669 TRACE("Mapping to parameter %p, having object id %u.\n", refpar
, refpar
->object_id
);
5670 if (refpar
->type
== D3DXPT_VERTEXSHADER
|| refpar
->type
== D3DXPT_PIXELSHADER
)
5672 struct d3dx_object
*refobj
= &base
->objects
[refpar
->object_id
];
5674 if (!refpar
->param_eval
)
5675 d3dx_create_param_eval(base
, refobj
->data
, refobj
->size
,
5676 refpar
->type
, &refpar
->param_eval
);
5681 FIXME("Referenced parameter %s not found.\n", (char *)object
->data
);
5682 return D3DXERR_INVALIDDATA
;
5687 state
->type
= ST_ARRAY_SELECTOR
;
5688 if (FAILED(hr
= d3dx9_copy_data(base
, param
->object_id
, ptr
)))
5690 hr
= d3dx9_parse_array_selector(base
, param
);
5694 FIXME("Unknown usage %x\n", usage
);
5701 static HRESULT
d3dx9_parse_effect(struct d3dx9_base_effect
*base
, const char *data
, UINT data_size
, DWORD start
)
5703 const char *ptr
= data
+ start
;
5704 UINT stringcount
, resourcecount
;
5708 read_dword(&ptr
, &base
->parameter_count
);
5709 TRACE("Parameter count: %u\n", base
->parameter_count
);
5711 read_dword(&ptr
, &base
->technique_count
);
5712 TRACE("Technique count: %u\n", base
->technique_count
);
5714 skip_dword_unknown(&ptr
, 1);
5716 read_dword(&ptr
, &base
->object_count
);
5717 TRACE("Object count: %u\n", base
->object_count
);
5719 base
->objects
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*base
->objects
) * base
->object_count
);
5722 ERR("Out of memory\n");
5727 if (base
->parameter_count
)
5729 base
->parameters
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
5730 sizeof(*base
->parameters
) * base
->parameter_count
);
5731 if (!base
->parameters
)
5733 ERR("Out of memory\n");
5738 for (i
= 0; i
< base
->parameter_count
; ++i
)
5740 add_param_to_table(base
, &base
->parameters
[i
]);
5741 hr
= d3dx9_parse_effect_parameter(base
, &base
->parameters
[i
], data
, &ptr
, base
->objects
);
5744 WARN("Failed to parse parameter %u\n", i
);
5750 if (base
->technique_count
)
5752 base
->techniques
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
5753 sizeof(*base
->techniques
) * base
->technique_count
);
5754 if (!base
->techniques
)
5756 ERR("Out of memory\n");
5761 for (i
= 0; i
< base
->technique_count
; ++i
)
5763 TRACE("Parsing technique %u.\n", i
);
5764 hr
= d3dx9_parse_effect_technique(base
, &base
->techniques
[i
], data
, &ptr
, base
->objects
);
5767 WARN("Failed to parse technique %u\n", i
);
5773 sync_param_handles(base
);
5775 read_dword(&ptr
, &stringcount
);
5776 TRACE("String count: %u\n", stringcount
);
5778 read_dword(&ptr
, &resourcecount
);
5779 TRACE("Resource count: %u\n", resourcecount
);
5781 for (i
= 0; i
< stringcount
; ++i
)
5785 read_dword(&ptr
, &id
);
5786 TRACE("Id: %u\n", id
);
5788 if (FAILED(hr
= d3dx9_copy_data(base
, id
, &ptr
)))
5791 if (base
->objects
[id
].data
)
5793 if (FAILED(hr
= d3dx9_create_object(base
, &base
->objects
[id
])))
5798 for (i
= 0; i
< resourcecount
; ++i
)
5800 TRACE("parse resource %u\n", i
);
5802 hr
= d3dx9_parse_resource(base
, data
, &ptr
);
5805 WARN("Failed to parse resource %u\n", i
);
5814 if (base
->techniques
)
5816 for (i
= 0; i
< base
->technique_count
; ++i
)
5817 free_technique(&base
->techniques
[i
]);
5818 HeapFree(GetProcessHeap(), 0, base
->techniques
);
5819 base
->techniques
= NULL
;
5822 if (base
->parameters
)
5824 for (i
= 0; i
< base
->parameter_count
; ++i
)
5826 free_parameter(&base
->parameters
[i
], FALSE
, FALSE
);
5828 HeapFree(GetProcessHeap(), 0, base
->parameters
);
5829 base
->parameters
= NULL
;
5834 for (i
= 0; i
< base
->object_count
; ++i
)
5836 free_object(&base
->objects
[i
]);
5838 HeapFree(GetProcessHeap(), 0, base
->objects
);
5839 base
->objects
= NULL
;
5845 static HRESULT
d3dx9_base_effect_init(struct d3dx9_base_effect
*base
,
5846 const char *data
, SIZE_T data_size
, const D3D_SHADER_MACRO
*defines
, ID3DInclude
*include
,
5847 UINT eflags
, ID3DBlob
**errors
, struct ID3DXEffectImpl
*effect
)
5850 const char *ptr
= data
;
5852 ID3DBlob
*bytecode
= NULL
, *temp_errors
= NULL
;
5854 TRACE("base %p, data %p, data_size %lu, effect %p\n", base
, data
, data_size
, effect
);
5856 base
->effect
= effect
;
5858 read_dword(&ptr
, &tag
);
5859 TRACE("Tag: %x\n", tag
);
5861 if (tag
!= d3dx9_effect_version(9, 1))
5863 TRACE("HLSL ASCII effect, trying to compile it.\n");
5864 hr
= D3DCompile(data
, data_size
, NULL
, defines
, include
,
5865 "main", "fx_2_0", 0, eflags
, &bytecode
, &temp_errors
);
5868 WARN("Failed to compile ASCII effect.\n");
5870 ID3D10Blob_Release(bytecode
);
5872 TRACE("%s\n", (char *)ID3D10Blob_GetBufferPointer(temp_errors
));
5874 *errors
= temp_errors
;
5875 else if (temp_errors
)
5876 ID3D10Blob_Release(temp_errors
);
5881 FIXME("No output from effect compilation.\n");
5882 return D3DERR_INVALIDCALL
;
5885 *errors
= temp_errors
;
5886 else if (temp_errors
)
5887 ID3D10Blob_Release(temp_errors
);
5889 ptr
= ID3D10Blob_GetBufferPointer(bytecode
);
5890 read_dword(&ptr
, &tag
);
5891 TRACE("Tag: %x\n", tag
);
5894 read_dword(&ptr
, &offset
);
5895 TRACE("Offset: %x\n", offset
);
5897 hr
= d3dx9_parse_effect(base
, ptr
, data_size
, offset
);
5899 ID3D10Blob_Release(bytecode
);
5902 FIXME("Failed to parse effect.\n");
5909 static HRESULT
d3dx9_effect_init(struct ID3DXEffectImpl
*effect
, struct IDirect3DDevice9
*device
,
5910 const char *data
, SIZE_T data_size
, const D3D_SHADER_MACRO
*defines
, ID3DInclude
*include
,
5911 UINT eflags
, ID3DBlob
**error_messages
, struct ID3DXEffectPool
*pool
)
5915 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect
, device
, data
, data_size
, pool
);
5917 effect
->ID3DXEffect_iface
.lpVtbl
= &ID3DXEffect_Vtbl
;
5920 if (pool
) pool
->lpVtbl
->AddRef(pool
);
5921 effect
->pool
= pool
;
5923 IDirect3DDevice9_AddRef(device
);
5924 effect
->device
= device
;
5926 if (FAILED(hr
= d3dx9_base_effect_init(&effect
->base_effect
, data
, data_size
, defines
, include
,
5927 eflags
, error_messages
, effect
)))
5929 FIXME("Failed to parse effect, hr %#x.\n", hr
);
5930 free_effect(effect
);
5934 /* initialize defaults - check because of unsupported ascii effects */
5935 if (effect
->base_effect
.techniques
)
5937 effect
->active_technique
= &effect
->base_effect
.techniques
[0];
5938 effect
->active_pass
= NULL
;
5944 HRESULT WINAPI
D3DXCreateEffectEx(struct IDirect3DDevice9
*device
, const void *srcdata
, UINT srcdatalen
,
5945 const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, const char *skip_constants
, DWORD flags
,
5946 struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilation_errors
)
5948 struct ID3DXEffectImpl
*object
;
5951 TRACE("device %p, srcdata %p, srcdatalen %u, defines %p, include %p,"
5952 " skip_constants %p, flags %#x, pool %p, effect %p, compilation_errors %p.\n",
5953 device
, srcdata
, srcdatalen
, defines
, include
,
5954 skip_constants
, flags
, pool
, effect
, compilation_errors
);
5956 if (compilation_errors
)
5957 *compilation_errors
= NULL
;
5959 if (!device
|| !srcdata
)
5960 return D3DERR_INVALIDCALL
;
5965 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
5970 FIXME("skip_constants is not NULL, not supported yet.\n");
5972 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
5974 return E_OUTOFMEMORY
;
5976 hr
= d3dx9_effect_init(object
, device
, srcdata
, srcdatalen
, (const D3D_SHADER_MACRO
*)defines
,
5977 (ID3DInclude
*)include
, flags
, (ID3DBlob
**)compilation_errors
, pool
);
5980 WARN("Failed to create effect object.\n");
5981 HeapFree(GetProcessHeap(), 0, object
);
5985 *effect
= &object
->ID3DXEffect_iface
;
5987 TRACE("Created ID3DXEffect %p\n", object
);
5992 HRESULT WINAPI
D3DXCreateEffect(struct IDirect3DDevice9
*device
, const void *srcdata
, UINT srcdatalen
,
5993 const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, DWORD flags
,
5994 struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilation_errors
)
5996 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device
, srcdata
, srcdatalen
, defines
,
5997 include
, flags
, pool
, effect
, compilation_errors
);
5999 return D3DXCreateEffectEx(device
, srcdata
, srcdatalen
, defines
, include
, NULL
, flags
, pool
, effect
, compilation_errors
);
6002 static HRESULT
d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl
*compiler
,
6003 const char *data
, SIZE_T data_size
, const D3D_SHADER_MACRO
*defines
, ID3DInclude
*include
,
6004 UINT eflags
, ID3DBlob
**error_messages
)
6008 TRACE("effect %p, data %p, data_size %lu\n", compiler
, data
, data_size
);
6010 compiler
->ID3DXEffectCompiler_iface
.lpVtbl
= &ID3DXEffectCompiler_Vtbl
;
6013 if (FAILED(hr
= d3dx9_base_effect_init(&compiler
->base_effect
, data
, data_size
, defines
,
6014 include
, eflags
, error_messages
, NULL
)))
6016 FIXME("Failed to parse effect, hr %#x.\n", hr
);
6017 free_effect_compiler(compiler
);
6024 HRESULT WINAPI
D3DXCreateEffectCompiler(const char *srcdata
, UINT srcdatalen
, const D3DXMACRO
*defines
,
6025 ID3DXInclude
*include
, DWORD flags
, ID3DXEffectCompiler
**compiler
, ID3DXBuffer
**parse_errors
)
6027 struct ID3DXEffectCompilerImpl
*object
;
6030 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
6031 srcdata
, srcdatalen
, defines
, include
, flags
, compiler
, parse_errors
);
6033 if (!srcdata
|| !compiler
)
6035 WARN("Invalid arguments supplied\n");
6036 return D3DERR_INVALIDCALL
;
6039 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
6041 return E_OUTOFMEMORY
;
6043 hr
= d3dx9_effect_compiler_init(object
, srcdata
, srcdatalen
, (const D3D_SHADER_MACRO
*)defines
,
6044 (ID3DInclude
*)include
, flags
, (ID3DBlob
**)parse_errors
);
6047 WARN("Failed to initialize effect compiler\n");
6048 HeapFree(GetProcessHeap(), 0, object
);
6052 *compiler
= &object
->ID3DXEffectCompiler_iface
;
6054 TRACE("Created ID3DXEffectCompiler %p\n", object
);
6059 struct ID3DXEffectPoolImpl
6061 ID3DXEffectPool ID3DXEffectPool_iface
;
6065 static inline struct ID3DXEffectPoolImpl
*impl_from_ID3DXEffectPool(ID3DXEffectPool
*iface
)
6067 return CONTAINING_RECORD(iface
, struct ID3DXEffectPoolImpl
, ID3DXEffectPool_iface
);
6070 /*** IUnknown methods ***/
6071 static HRESULT WINAPI
ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool
*iface
, REFIID riid
, void **object
)
6073 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), object
);
6075 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
6076 IsEqualGUID(riid
, &IID_ID3DXEffectPool
))
6078 iface
->lpVtbl
->AddRef(iface
);
6083 WARN("Interface %s not found\n", debugstr_guid(riid
));
6085 return E_NOINTERFACE
;
6088 static ULONG WINAPI
ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool
*iface
)
6090 struct ID3DXEffectPoolImpl
*This
= impl_from_ID3DXEffectPool(iface
);
6092 TRACE("(%p)->(): AddRef from %u\n", This
, This
->ref
);
6094 return InterlockedIncrement(&This
->ref
);
6097 static ULONG WINAPI
ID3DXEffectPoolImpl_Release(ID3DXEffectPool
*iface
)
6099 struct ID3DXEffectPoolImpl
*This
= impl_from_ID3DXEffectPool(iface
);
6100 ULONG ref
= InterlockedDecrement(&This
->ref
);
6102 TRACE("(%p)->(): Release from %u\n", This
, ref
+ 1);
6105 HeapFree(GetProcessHeap(), 0, This
);
6110 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl
=
6112 /*** IUnknown methods ***/
6113 ID3DXEffectPoolImpl_QueryInterface
,
6114 ID3DXEffectPoolImpl_AddRef
,
6115 ID3DXEffectPoolImpl_Release
6118 HRESULT WINAPI
D3DXCreateEffectPool(ID3DXEffectPool
**pool
)
6120 struct ID3DXEffectPoolImpl
*object
;
6122 TRACE("(%p)\n", pool
);
6125 return D3DERR_INVALIDCALL
;
6127 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
6129 return E_OUTOFMEMORY
;
6131 object
->ID3DXEffectPool_iface
.lpVtbl
= &ID3DXEffectPool_Vtbl
;
6134 *pool
= &object
->ID3DXEffectPool_iface
;
6139 HRESULT WINAPI
D3DXCreateEffectFromFileExW(struct IDirect3DDevice9
*device
, const WCHAR
*srcfile
,
6140 const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, const char *skipconstants
, DWORD flags
,
6141 struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
6147 TRACE("device %p, srcfile %s, defines %p, include %p, skipconstants %s, "
6148 "flags %#x, pool %p, effect %p, compilationerrors %p.\n",
6149 device
, debugstr_w(srcfile
), defines
, include
, debugstr_a(skipconstants
),
6150 flags
, pool
, effect
, compilationerrors
);
6152 if (!device
|| !srcfile
)
6153 return D3DERR_INVALIDCALL
;
6155 ret
= map_view_of_file(srcfile
, &buffer
, &size
);
6158 return D3DXERR_INVALIDDATA
;
6160 ret
= D3DXCreateEffectEx(device
, buffer
, size
, defines
, include
, skipconstants
, flags
, pool
, effect
, compilationerrors
);
6161 UnmapViewOfFile(buffer
);
6166 HRESULT WINAPI
D3DXCreateEffectFromFileExA(struct IDirect3DDevice9
*device
, const char *srcfile
,
6167 const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, const char *skipconstants
, DWORD flags
,
6168 struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
6174 TRACE("device %p, srcfile %s, defines %p, include %p, skipconstants %s, "
6175 "flags %#x, pool %p, effect %p, compilationerrors %p.\n",
6176 device
, debugstr_a(srcfile
), defines
, include
, debugstr_a(skipconstants
),
6177 flags
, pool
, effect
, compilationerrors
);
6180 return D3DERR_INVALIDCALL
;
6182 len
= MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, NULL
, 0);
6183 srcfileW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(*srcfileW
));
6184 MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, srcfileW
, len
);
6186 ret
= D3DXCreateEffectFromFileExW(device
, srcfileW
, defines
, include
, skipconstants
, flags
, pool
, effect
, compilationerrors
);
6187 HeapFree(GetProcessHeap(), 0, srcfileW
);
6192 HRESULT WINAPI
D3DXCreateEffectFromFileW(struct IDirect3DDevice9
*device
, const WCHAR
*srcfile
,
6193 const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, DWORD flags
, struct ID3DXEffectPool
*pool
,
6194 struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
6196 TRACE("(void): relay\n");
6197 return D3DXCreateEffectFromFileExW(device
, srcfile
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
6200 HRESULT WINAPI
D3DXCreateEffectFromFileA(struct IDirect3DDevice9
*device
, const char *srcfile
,
6201 const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, DWORD flags
, struct ID3DXEffectPool
*pool
,
6202 struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
6204 TRACE("(void): relay\n");
6205 return D3DXCreateEffectFromFileExA(device
, srcfile
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
6208 HRESULT WINAPI
D3DXCreateEffectFromResourceExW(struct IDirect3DDevice9
*device
, HMODULE srcmodule
,
6209 const WCHAR
*srcresource
, const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, const char *skipconstants
,
6210 DWORD flags
, struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
6216 TRACE("device %p, srcmodule %p, srcresource %s, defines %p, include %p, skipconstants %s, "
6217 "flags %#x, pool %p, effect %p, compilationerrors %p.\n",
6218 device
, srcmodule
, debugstr_w(srcresource
), defines
, include
, debugstr_a(skipconstants
),
6219 flags
, pool
, effect
, compilationerrors
);
6222 return D3DERR_INVALIDCALL
;
6224 if (!(resinfo
= FindResourceW(srcmodule
, srcresource
, (const WCHAR
*)RT_RCDATA
)))
6225 return D3DXERR_INVALIDDATA
;
6227 if (FAILED(load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
)))
6228 return D3DXERR_INVALIDDATA
;
6230 return D3DXCreateEffectEx(device
, buffer
, size
, defines
, include
,
6231 skipconstants
, flags
, pool
, effect
, compilationerrors
);
6234 HRESULT WINAPI
D3DXCreateEffectFromResourceExA(struct IDirect3DDevice9
*device
, HMODULE srcmodule
,
6235 const char *srcresource
, const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, const char *skipconstants
,
6236 DWORD flags
, struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
6242 TRACE("device %p, srcmodule %p, srcresource %s, defines %p, include %p, skipconstants %s, "
6243 "flags %#x, pool %p, effect %p, compilationerrors %p.\n",
6244 device
, srcmodule
, debugstr_a(srcresource
), defines
, include
, debugstr_a(skipconstants
),
6245 flags
, pool
, effect
, compilationerrors
);
6248 return D3DERR_INVALIDCALL
;
6250 if (!(resinfo
= FindResourceA(srcmodule
, srcresource
, (const char *)RT_RCDATA
)))
6251 return D3DXERR_INVALIDDATA
;
6253 if (FAILED(load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
)))
6254 return D3DXERR_INVALIDDATA
;
6256 return D3DXCreateEffectEx(device
, buffer
, size
, defines
, include
,
6257 skipconstants
, flags
, pool
, effect
, compilationerrors
);
6260 HRESULT WINAPI
D3DXCreateEffectFromResourceW(struct IDirect3DDevice9
*device
, HMODULE srcmodule
,
6261 const WCHAR
*srcresource
, const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, DWORD flags
,
6262 struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
6264 TRACE("(void): relay\n");
6265 return D3DXCreateEffectFromResourceExW(device
, srcmodule
, srcresource
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
6268 HRESULT WINAPI
D3DXCreateEffectFromResourceA(struct IDirect3DDevice9
*device
, HMODULE srcmodule
,
6269 const char *srcresource
, const D3DXMACRO
*defines
, struct ID3DXInclude
*include
, DWORD flags
,
6270 struct ID3DXEffectPool
*pool
, struct ID3DXEffect
**effect
, struct ID3DXBuffer
**compilationerrors
)
6272 TRACE("(void): relay\n");
6273 return D3DXCreateEffectFromResourceExA(device
, srcmodule
, srcresource
, defines
, include
, NULL
, flags
, pool
, effect
, compilationerrors
);
6276 HRESULT WINAPI
D3DXCreateEffectCompilerFromFileW(const WCHAR
*srcfile
, const D3DXMACRO
*defines
,
6277 ID3DXInclude
*include
, DWORD flags
, ID3DXEffectCompiler
**effectcompiler
, ID3DXBuffer
**parseerrors
)
6283 TRACE("srcfile %s, defines %p, include %p, flags %#x, effectcompiler %p, parseerrors %p.\n",
6284 debugstr_w(srcfile
), defines
, include
, flags
, effectcompiler
, parseerrors
);
6287 return D3DERR_INVALIDCALL
;
6289 ret
= map_view_of_file(srcfile
, &buffer
, &size
);
6292 return D3DXERR_INVALIDDATA
;
6294 ret
= D3DXCreateEffectCompiler(buffer
, size
, defines
, include
, flags
, effectcompiler
, parseerrors
);
6295 UnmapViewOfFile(buffer
);
6300 HRESULT WINAPI
D3DXCreateEffectCompilerFromFileA(const char *srcfile
, const D3DXMACRO
*defines
,
6301 ID3DXInclude
*include
, DWORD flags
, ID3DXEffectCompiler
**effectcompiler
, ID3DXBuffer
**parseerrors
)
6307 TRACE("srcfile %s, defines %p, include %p, flags %#x, effectcompiler %p, parseerrors %p.\n",
6308 debugstr_a(srcfile
), defines
, include
, flags
, effectcompiler
, parseerrors
);
6311 return D3DERR_INVALIDCALL
;
6313 len
= MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, NULL
, 0);
6314 srcfileW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(*srcfileW
));
6315 MultiByteToWideChar(CP_ACP
, 0, srcfile
, -1, srcfileW
, len
);
6317 ret
= D3DXCreateEffectCompilerFromFileW(srcfileW
, defines
, include
, flags
, effectcompiler
, parseerrors
);
6318 HeapFree(GetProcessHeap(), 0, srcfileW
);
6323 HRESULT WINAPI
D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule
, const char *srcresource
,
6324 const D3DXMACRO
*defines
, ID3DXInclude
*include
, DWORD flags
,
6325 ID3DXEffectCompiler
**effectcompiler
, ID3DXBuffer
**parseerrors
)
6331 TRACE("srcmodule %p, srcresource %s, defines %p, include %p, flags %#x, effectcompiler %p, parseerrors %p.\n",
6332 srcmodule
, debugstr_a(srcresource
), defines
, include
, flags
, effectcompiler
, parseerrors
);
6334 if (!(resinfo
= FindResourceA(srcmodule
, srcresource
, (const char *)RT_RCDATA
)))
6335 return D3DXERR_INVALIDDATA
;
6337 if (FAILED(load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
)))
6338 return D3DXERR_INVALIDDATA
;
6340 return D3DXCreateEffectCompiler(buffer
, size
, defines
, include
, flags
, effectcompiler
, parseerrors
);
6343 HRESULT WINAPI
D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule
, const WCHAR
*srcresource
,
6344 const D3DXMACRO
*defines
, ID3DXInclude
*include
, DWORD flags
,
6345 ID3DXEffectCompiler
**effectcompiler
, ID3DXBuffer
**parseerrors
)
6351 TRACE("srcmodule %p, srcresource %s, defines %p, include %p, flags %#x, effectcompiler %p, parseerrors %p.\n",
6352 srcmodule
, debugstr_w(srcresource
), defines
, include
, flags
, effectcompiler
, parseerrors
);
6354 if (!(resinfo
= FindResourceW(srcmodule
, srcresource
, (const WCHAR
*)RT_RCDATA
)))
6355 return D3DXERR_INVALIDDATA
;
6357 if (FAILED(load_resource_into_memory(srcmodule
, resinfo
, &buffer
, &size
)))
6358 return D3DXERR_INVALIDDATA
;
6360 return D3DXCreateEffectCompiler(buffer
, size
, defines
, include
, flags
, effectcompiler
, parseerrors
);
6363 HRESULT WINAPI
D3DXDisassembleEffect(ID3DXEffect
*effect
, BOOL enable_color_code
, ID3DXBuffer
**disassembly
)
6365 FIXME("(%p, %u, %p): stub\n", effect
, enable_color_code
, disassembly
);
6367 return D3DXERR_INVALIDDATA
;