d3dcompiler: Implement ID3D11ShaderReflectionType::GetDesc().
[wine] / dlls / d3dx9_36 / effect.c
1 /*
2  * Copyright 2010 Christian Costa
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20 #include "wine/port.h"
21 #include "wine/debug.h"
22 #include "wine/unicode.h"
23 #include "windef.h"
24 #include "wingdi.h"
25 #include "d3dx9_36_private.h"
26
27 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
28
29 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl;
30
31 typedef struct ID3DXEffectImpl {
32     ID3DXEffect ID3DXEffect_iface;
33     LONG ref;
34 } ID3DXEffectImpl;
35
36 static inline ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
37 {
38     return CONTAINING_RECORD(iface, ID3DXEffectImpl, ID3DXEffect_iface);
39 }
40
41 /*** IUnknown methods ***/
42 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect* iface, REFIID riid, void** object)
43 {
44     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
45
46     TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
47
48     if (IsEqualGUID(riid, &IID_IUnknown) ||
49         IsEqualGUID(riid, &IID_ID3DXBaseEffect) ||
50         IsEqualGUID(riid, &IID_ID3DXEffect))
51     {
52         This->ID3DXEffect_iface.lpVtbl->AddRef(iface);
53         *object = This;
54         return S_OK;
55     }
56
57     ERR("Interface %s not found\n", debugstr_guid(riid));
58
59     return E_NOINTERFACE;
60 }
61
62 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect* iface)
63 {
64     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
65
66     TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
67
68     return InterlockedIncrement(&This->ref);
69 }
70
71 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect* iface)
72 {
73     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
74     ULONG ref = InterlockedDecrement(&This->ref);
75
76     TRACE("(%p)->(): Release from %u\n", This, ref + 1);
77
78     if (!ref)
79         HeapFree(GetProcessHeap(), 0, This);
80
81     return ref;
82 }
83
84 /*** ID3DXBaseEffect methods ***/
85 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect* iface, D3DXEFFECT_DESC* desc)
86 {
87     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
88
89     FIXME("(%p)->(%p): stub\n", This, desc);
90
91     return E_NOTIMPL;
92 }
93
94 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC* desc)
95 {
96     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
97
98     FIXME("(%p)->(%p, %p): stub\n", This, parameter, desc);
99
100     return E_NOTIMPL;
101 }
102
103 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect* iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC* desc)
104 {
105     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
106
107     FIXME("(%p)->(%p, %p): stub\n", This, technique, desc);
108
109     return E_NOTIMPL;
110 }
111
112 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect* iface, D3DXHANDLE pass, D3DXPASS_DESC* desc)
113 {
114     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
115
116     FIXME("(%p)->(%p, %p): stub\n", This, pass, desc);
117
118     return E_NOTIMPL;
119 }
120
121 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect* iface, D3DXHANDLE shader, D3DXFUNCTION_DESC* desc)
122 {
123     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
124
125     FIXME("(%p)->(%p, %p): stub\n", This, shader, desc);
126
127     return E_NOTIMPL;
128 }
129
130 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect* iface, D3DXHANDLE parameter, UINT index)
131 {
132     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
133
134     FIXME("(%p)->(%p, %u): stub\n", This, parameter, index);
135
136     return NULL;
137 }
138
139 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect* iface, D3DXHANDLE parameter, LPCSTR name)
140 {
141     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
142
143     FIXME("(%p)->(%p, %s): stub\n", This, parameter, name);
144
145     return NULL;
146 }
147
148 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect* iface, D3DXHANDLE parameter, LPCSTR semantic)
149 {
150     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
151
152     FIXME("(%p)->(%p, %s): stub\n", This, parameter, semantic);
153
154     return NULL;
155 }
156
157 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect* iface, D3DXHANDLE parameter, UINT index)
158 {
159     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
160
161     FIXME("(%p)->(%p, %u): stub\n", This, parameter, index);
162
163     return NULL;
164 }
165
166 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect* iface, UINT index)
167 {
168     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
169
170     FIXME("(%p)->(%u): stub\n", This, index);
171
172     return NULL;
173 }
174
175 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect* iface, LPCSTR name)
176 {
177     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
178
179     FIXME("(%p)->(%s): stub\n", This, name);
180
181     return NULL;
182 }
183
184 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect* iface, D3DXHANDLE technique, UINT index)
185 {
186     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
187
188     FIXME("(%p)->(%p, %u): stub\n", This, technique, index);
189
190     return NULL;
191 }
192
193 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect* iface, D3DXHANDLE technique, LPCSTR name)
194 {
195     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
196
197     FIXME("(%p)->(%p, %s): stub\n", This, technique, name);
198
199     return NULL;
200 }
201
202 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect* iface, UINT index)
203 {
204     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
205
206     FIXME("(%p)->(%u): stub\n", This, index);
207
208     return NULL;
209 }
210
211 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect* iface, LPCSTR name)
212 {
213     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
214
215     FIXME("(%p)->(%s): stub\n", This, name);
216
217     return NULL;
218 }
219
220 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect* iface, D3DXHANDLE object, UINT index)
221 {
222     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
223
224     FIXME("(%p)->(%p, %u): stub\n", This, object, index);
225
226     return NULL;
227 }
228
229 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect* iface, D3DXHANDLE object, LPCSTR name)
230 {
231     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
232
233     FIXME("(%p)->(%p, %s): stub\n", This, object, name);
234
235     return NULL;
236 }
237
238 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
239 {
240     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
241
242     FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, data, bytes);
243
244     return E_NOTIMPL;
245 }
246
247 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
248 {
249     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
250
251     FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, data, bytes);
252
253     return E_NOTIMPL;
254 }
255
256 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect* iface, D3DXHANDLE parameter, BOOL b)
257 {
258     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
259
260     FIXME("(%p)->(%p, %u): stub\n", This, parameter, b);
261
262     return E_NOTIMPL;
263 }
264
265 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect* iface, D3DXHANDLE parameter, BOOL* b)
266 {
267     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
268
269     FIXME("(%p)->(%p, %p): stub\n", This, parameter, b);
270
271     return E_NOTIMPL;
272 }
273
274 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect* iface, D3DXHANDLE parameter, CONST BOOL* b, UINT count)
275 {
276     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
277
278     FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, b, count);
279
280     return E_NOTIMPL;
281 }
282
283 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect* iface, D3DXHANDLE parameter, BOOL* b, UINT count)
284 {
285     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
286
287     FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, b, count);
288
289     return E_NOTIMPL;
290 }
291
292 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect* iface, D3DXHANDLE parameter, INT n)
293 {
294     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
295
296     FIXME("(%p)->(%p, %d): stub\n", This, parameter, n);
297
298     return E_NOTIMPL;
299 }
300
301 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect* iface, D3DXHANDLE parameter, INT* n)
302 {
303     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
304
305     FIXME("(%p)->(%p, %p): stub\n", This, parameter, n);
306
307     return E_NOTIMPL;
308 }
309
310 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect* iface, D3DXHANDLE parameter, CONST INT* n, UINT count)
311 {
312     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
313
314     FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, n, count);
315
316     return E_NOTIMPL;
317 }
318
319 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect* iface, D3DXHANDLE parameter, INT* n, UINT count)
320 {
321     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
322
323     FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, n, count);
324
325     return E_NOTIMPL;
326 }
327
328 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect* iface, D3DXHANDLE parameter, FLOAT f)
329 {
330     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
331
332     FIXME("(%p)->(%p, %f): stub\n", This, parameter, f);
333
334     return E_NOTIMPL;
335 }
336
337 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect* iface, D3DXHANDLE parameter, FLOAT* f)
338 {
339     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
340
341     FIXME("(%p)->(%p, %p): stub\n", This, parameter, f);
342
343     return E_NOTIMPL;
344 }
345
346 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect* iface, D3DXHANDLE parameter, CONST FLOAT* f, UINT count)
347 {
348     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
349
350     FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, f, count);
351
352     return E_NOTIMPL;
353 }
354
355 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect* iface, D3DXHANDLE parameter, FLOAT* f, UINT count)
356 {
357     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
358
359     FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, f, count);
360
361     return E_NOTIMPL;
362 }
363
364 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect* iface, D3DXHANDLE parameter, CONST D3DXVECTOR4* vector)
365 {
366     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
367
368     FIXME("(%p)->(%p, %p): stub\n", This, parameter, vector);
369
370     return E_NOTIMPL;
371 }
372
373 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXVECTOR4* vector)
374 {
375     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
376
377     FIXME("(%p)->(%p, %p): stub\n", This, parameter, vector);
378
379     return E_NOTIMPL;
380 }
381
382 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect* iface, D3DXHANDLE parameter, CONST D3DXVECTOR4* vector, UINT count)
383 {
384     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
385
386     FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, vector, count);
387
388     return E_NOTIMPL;
389 }
390
391 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXVECTOR4* vector, UINT count)
392 {
393     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
394
395     FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, vector, count);
396
397     return E_NOTIMPL;
398 }
399
400 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect* iface, D3DXHANDLE parameter, CONST D3DXMATRIX* matrix)
401 {
402     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
403
404     FIXME("(%p)->(%p, %p): stub\n", This, parameter, matrix);
405
406     return E_NOTIMPL;
407 }
408
409 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXMATRIX* matrix)
410 {
411     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
412
413     FIXME("(%p)->(%p, %p): stub\n", This, parameter, matrix);
414
415     return E_NOTIMPL;
416 }
417
418 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect* iface, D3DXHANDLE parameter, CONST D3DXMATRIX* matrix, UINT count)
419 {
420     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
421
422     FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, matrix, count);
423
424     return E_NOTIMPL;
425 }
426
427 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXMATRIX* matrix, UINT count)
428 {
429     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
430
431     FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, matrix, count);
432
433     return E_NOTIMPL;
434 }
435
436 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect* iface, D3DXHANDLE parameter, CONST D3DXMATRIX** matrix, UINT count)
437 {
438     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
439
440     FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, matrix, count);
441
442     return E_NOTIMPL;
443 }
444
445 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXMATRIX** matrix, UINT count)
446 {
447     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
448
449     FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, matrix, count);
450
451     return E_NOTIMPL;
452 }
453
454 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect* iface, D3DXHANDLE parameter, CONST D3DXMATRIX* matrix)
455 {
456     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
457
458     FIXME("(%p)->(%p, %p): stub\n", This, parameter, matrix);
459
460     return E_NOTIMPL;
461 }
462
463 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXMATRIX* matrix)
464 {
465     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
466
467     FIXME("(%p)->(%p, %p): stub\n", This, parameter, matrix);
468
469     return E_NOTIMPL;
470 }
471
472 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect* iface, D3DXHANDLE parameter, CONST D3DXMATRIX* matrix, UINT count)
473 {
474     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
475
476     FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, matrix, count);
477
478     return E_NOTIMPL;
479 }
480
481 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXMATRIX* matrix, UINT count)
482 {
483     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
484
485     FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, matrix, count);
486
487     return E_NOTIMPL;
488 }
489
490 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect* iface, D3DXHANDLE parameter, CONST D3DXMATRIX** matrix, UINT count)
491 {
492     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
493
494     FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, matrix, count);
495
496     return E_NOTIMPL;
497 }
498
499 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXMATRIX** matrix, UINT count)
500 {
501     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
502
503     FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, matrix, count);
504
505     return E_NOTIMPL;
506 }
507
508 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect* iface, D3DXHANDLE parameter, LPCSTR string)
509 {
510     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
511
512     FIXME("(%p)->(%p, %p): stub\n", This, parameter, string);
513
514     return E_NOTIMPL;
515 }
516
517 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect* iface, D3DXHANDLE parameter, LPCSTR* string)
518 {
519     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
520
521     FIXME("(%p)->(%p, %p): stub\n", This, parameter, string);
522
523     return E_NOTIMPL;
524 }
525
526 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect* iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
527 {
528     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
529
530     FIXME("(%p)->(%p, %p): stub\n", This, parameter, texture);
531
532     return E_NOTIMPL;
533 }
534
535 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect* iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9* texture)
536 {
537     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
538
539     FIXME("(%p)->(%p, %p): stub\n", This, parameter, texture);
540
541     return E_NOTIMPL;
542 }
543
544 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect* iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9* pshader)
545 {
546     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
547
548     FIXME("(%p)->(%p, %p): stub\n", This, parameter, pshader);
549
550     return E_NOTIMPL;
551 }
552
553 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect* iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9* vshader)
554 {
555     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
556
557     FIXME("(%p)->(%p, %p): stub\n", This, parameter, vshader);
558
559     return E_NOTIMPL;
560 }
561
562 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect* iface, D3DXHANDLE parameter, UINT start, UINT end)
563 {
564     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
565
566     FIXME("(%p)->(%p, %u, %u): stub\n", This, parameter, start, end);
567
568     return E_NOTIMPL;
569 }
570
571 /*** ID3DXEffect methods ***/
572 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect* iface, LPD3DXEFFECTPOOL* pool)
573 {
574     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
575
576     FIXME("(%p)->(%p): stub\n", This, pool);
577
578     return E_NOTIMPL;
579 }
580
581 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
582 {
583     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
584
585     FIXME("(%p)->(%p): stub\n", This, technique);
586
587     return E_NOTIMPL;
588 }
589
590 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect* iface)
591 {
592     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
593
594     FIXME("(%p)->(): stub\n", This);
595
596     return NULL;
597 }
598
599 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
600 {
601     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
602
603     FIXME("(%p)->(%p): stub\n", This, technique);
604
605     return D3D_OK;
606 }
607
608 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
609 {
610     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
611
612     FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
613
614     return E_NOTIMPL;
615 }
616
617 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
618 {
619     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
620
621     FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
622
623     return FALSE;
624 }
625
626 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect* iface, UINT *passes, DWORD flags)
627 {
628     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
629
630     FIXME("(%p)->(%p, %#x): stub\n", This, passes, flags);
631
632     return E_NOTIMPL;
633 }
634
635 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect* iface, UINT pass)
636 {
637     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
638
639     FIXME("(%p)->(%u): stub\n", This, pass);
640
641     return E_NOTIMPL;
642 }
643
644 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
645 {
646     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
647
648     FIXME("(%p)->(): stub\n", This);
649
650     return E_NOTIMPL;
651 }
652
653 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect* iface)
654 {
655     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
656
657     FIXME("(%p)->(): stub\n", This);
658
659     return E_NOTIMPL;
660 }
661
662 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
663 {
664     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
665
666     FIXME("(%p)->(): stub\n", This);
667
668     return E_NOTIMPL;
669 }
670
671 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect* iface, LPDIRECT3DDEVICE9* device)
672 {
673     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
674
675     FIXME("(%p)->(%p): stub\n", This, device);
676
677     return E_NOTIMPL;
678 }
679
680 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
681 {
682     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
683
684     FIXME("(%p)->(): stub\n", This);
685
686     return E_NOTIMPL;
687 }
688
689 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
690 {
691     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
692
693     FIXME("(%p)->(): stub\n", This);
694
695     return E_NOTIMPL;
696 }
697
698 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect* iface, LPD3DXEFFECTSTATEMANAGER manager)
699 {
700     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
701
702     FIXME("(%p)->(%p): stub\n", This, manager);
703
704     return E_NOTIMPL;
705 }
706
707 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect* iface, LPD3DXEFFECTSTATEMANAGER* manager)
708 {
709     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
710
711     FIXME("(%p)->(%p): stub\n", This, manager);
712
713     return E_NOTIMPL;
714 }
715
716 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
717 {
718     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
719
720     FIXME("(%p)->(): stub\n", This);
721
722     return E_NOTIMPL;
723 }
724
725 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
726 {
727     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
728
729     FIXME("(%p)->(): stub\n", This);
730
731     return NULL;
732 }
733
734 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
735 {
736     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
737
738     FIXME("(%p)->(%p): stub\n", This, parameter_block);
739
740     return E_NOTIMPL;
741 }
742
743 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
744 {
745     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
746
747     FIXME("(%p)->(%p): stub\n", This, parameter_block);
748
749     return E_NOTIMPL;
750 }
751
752 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
753 {
754     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
755
756     FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
757
758     return E_NOTIMPL;
759 }
760
761 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
762 {
763     ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
764
765     FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
766
767     return E_NOTIMPL;
768 }
769
770 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
771 {
772     /*** IUnknown methods ***/
773     ID3DXEffectImpl_QueryInterface,
774     ID3DXEffectImpl_AddRef,
775     ID3DXEffectImpl_Release,
776     /*** ID3DXBaseEffect methods ***/
777     ID3DXEffectImpl_GetDesc,
778     ID3DXEffectImpl_GetParameterDesc,
779     ID3DXEffectImpl_GetTechniqueDesc,
780     ID3DXEffectImpl_GetPassDesc,
781     ID3DXEffectImpl_GetFunctionDesc,
782     ID3DXEffectImpl_GetParameter,
783     ID3DXEffectImpl_GetParameterByName,
784     ID3DXEffectImpl_GetParameterBySemantic,
785     ID3DXEffectImpl_GetParameterElement,
786     ID3DXEffectImpl_GetTechnique,
787     ID3DXEffectImpl_GetTechniqueByName,
788     ID3DXEffectImpl_GetPass,
789     ID3DXEffectImpl_GetPassByName,
790     ID3DXEffectImpl_GetFunction,
791     ID3DXEffectImpl_GetFunctionByName,
792     ID3DXEffectImpl_GetAnnotation,
793     ID3DXEffectImpl_GetAnnotationByName,
794     ID3DXEffectImpl_SetValue,
795     ID3DXEffectImpl_GetValue,
796     ID3DXEffectImpl_SetBool,
797     ID3DXEffectImpl_GetBool,
798     ID3DXEffectImpl_SetBoolArray,
799     ID3DXEffectImpl_GetBoolArray,
800     ID3DXEffectImpl_SetInt,
801     ID3DXEffectImpl_GetInt,
802     ID3DXEffectImpl_SetIntArray,
803     ID3DXEffectImpl_GetIntArray,
804     ID3DXEffectImpl_SetFloat,
805     ID3DXEffectImpl_GetFloat,
806     ID3DXEffectImpl_SetFloatArray,
807     ID3DXEffectImpl_GetFloatArray,
808     ID3DXEffectImpl_SetVector,
809     ID3DXEffectImpl_GetVector,
810     ID3DXEffectImpl_SetVectorArray,
811     ID3DXEffectImpl_GetVectorArray,
812     ID3DXEffectImpl_SetMatrix,
813     ID3DXEffectImpl_GetMatrix,
814     ID3DXEffectImpl_SetMatrixArray,
815     ID3DXEffectImpl_GetMatrixArray,
816     ID3DXEffectImpl_SetMatrixPointerArray,
817     ID3DXEffectImpl_GetMatrixPointerArray,
818     ID3DXEffectImpl_SetMatrixTranspose,
819     ID3DXEffectImpl_GetMatrixTranspose,
820     ID3DXEffectImpl_SetMatrixTransposeArray,
821     ID3DXEffectImpl_GetMatrixTransposeArray,
822     ID3DXEffectImpl_SetMatrixTransposePointerArray,
823     ID3DXEffectImpl_GetMatrixTransposePointerArray,
824     ID3DXEffectImpl_SetString,
825     ID3DXEffectImpl_GetString,
826     ID3DXEffectImpl_SetTexture,
827     ID3DXEffectImpl_GetTexture,
828     ID3DXEffectImpl_GetPixelShader,
829     ID3DXEffectImpl_GetVertexShader,
830     ID3DXEffectImpl_SetArrayRange,
831     /*** ID3DXEffect methods ***/
832     ID3DXEffectImpl_GetPool,
833     ID3DXEffectImpl_SetTechnique,
834     ID3DXEffectImpl_GetCurrentTechnique,
835     ID3DXEffectImpl_ValidateTechnique,
836     ID3DXEffectImpl_FindNextValidTechnique,
837     ID3DXEffectImpl_IsParameterUsed,
838     ID3DXEffectImpl_Begin,
839     ID3DXEffectImpl_BeginPass,
840     ID3DXEffectImpl_CommitChanges,
841     ID3DXEffectImpl_EndPass,
842     ID3DXEffectImpl_End,
843     ID3DXEffectImpl_GetDevice,
844     ID3DXEffectImpl_OnLostDevice,
845     ID3DXEffectImpl_OnResetDevice,
846     ID3DXEffectImpl_SetStateManager,
847     ID3DXEffectImpl_GetStateManager,
848     ID3DXEffectImpl_BeginParameterBlock,
849     ID3DXEffectImpl_EndParameterBlock,
850     ID3DXEffectImpl_ApplyParameterBlock,
851     ID3DXEffectImpl_DeleteParameterBlock,
852     ID3DXEffectImpl_CloneEffect,
853     ID3DXEffectImpl_SetRawValue
854 };
855
856 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
857                                   LPCVOID srcdata,
858                                   UINT srcdatalen,
859                                   CONST D3DXMACRO* defines,
860                                   LPD3DXINCLUDE include,
861                                   LPCSTR skip_constants,
862                                   DWORD flags,
863                                   LPD3DXEFFECTPOOL pool,
864                                   LPD3DXEFFECT* effect,
865                                   LPD3DXBUFFER* compilation_errors)
866 {
867     ID3DXEffectImpl* object;
868
869     FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
870         skip_constants, flags, pool, effect, compilation_errors);
871
872     if (!device || !srcdata)
873         return D3DERR_INVALIDCALL;
874
875     if (!srcdatalen)
876         return E_FAIL;
877
878     /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
879     if (!effect)
880         return D3D_OK;
881
882     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ID3DXEffectImpl));
883     if (!object)
884     {
885         ERR("Out of memory\n");
886         return E_OUTOFMEMORY;
887     }
888
889     object->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
890     object->ref = 1;
891
892     *effect = &object->ID3DXEffect_iface;
893
894     return D3D_OK;
895 }
896
897 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
898                                 LPCVOID srcdata,
899                                 UINT srcdatalen,
900                                 CONST D3DXMACRO* defines,
901                                 LPD3DXINCLUDE include,
902                                 DWORD flags,
903                                 LPD3DXEFFECTPOOL pool,
904                                 LPD3DXEFFECT* effect,
905                                 LPD3DXBUFFER* compilation_errors)
906 {
907     TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
908         include, flags, pool, effect, compilation_errors);
909
910     return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
911 }
912
913 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
914                                         UINT srcdatalen,
915                                         CONST D3DXMACRO* defines,
916                                         LPD3DXINCLUDE include,
917                                         DWORD flags,
918                                         LPD3DXEFFECTCOMPILER* compiler,
919                                         LPD3DXBUFFER* parse_errors)
920 {
921     FIXME("(%p, %u, %p, %p, %#x, %p, %p): stub\n", srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
922
923     return E_NOTIMPL;
924 }
925
926 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
927
928 typedef struct ID3DXEffectPoolImpl {
929     ID3DXEffectPool ID3DXEffectPool_iface;
930     LONG ref;
931 } ID3DXEffectPoolImpl;
932
933 static inline ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
934 {
935     return CONTAINING_RECORD(iface, ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
936 }
937
938 /*** IUnknown methods ***/
939 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool* iface, REFIID riid, void** object)
940 {
941     ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
942
943     TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
944
945     if (IsEqualGUID(riid, &IID_IUnknown) ||
946         IsEqualGUID(riid, &IID_ID3DXEffectPool))
947     {
948         This->ID3DXEffectPool_iface.lpVtbl->AddRef(iface);
949         *object = This;
950         return S_OK;
951     }
952
953     WARN("Interface %s not found\n", debugstr_guid(riid));
954
955     return E_NOINTERFACE;
956 }
957
958 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool* iface)
959 {
960     ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
961
962     TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
963
964     return InterlockedIncrement(&This->ref);
965 }
966
967 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool* iface)
968 {
969     ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
970     ULONG ref = InterlockedDecrement(&This->ref);
971
972     TRACE("(%p)->(): Release from %u\n", This, ref + 1);
973
974     if (!ref)
975         HeapFree(GetProcessHeap(), 0, This);
976
977     return ref;
978 }
979
980 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
981 {
982     /*** IUnknown methods ***/
983     ID3DXEffectPoolImpl_QueryInterface,
984     ID3DXEffectPoolImpl_AddRef,
985     ID3DXEffectPoolImpl_Release
986 };
987
988 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL* pool)
989 {
990     ID3DXEffectPoolImpl* object;
991
992     TRACE("(%p)\n", pool);
993
994     if (!pool)
995         return D3DERR_INVALIDCALL;
996
997     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ID3DXEffectImpl));
998     if (!object)
999     {
1000         ERR("Out of memory\n");
1001         return E_OUTOFMEMORY;
1002     }
1003
1004     object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
1005     object->ref = 1;
1006
1007     *pool = &object->ID3DXEffectPool_iface;
1008
1009     return S_OK;
1010 }
1011
1012 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
1013     const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
1014     LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
1015 {
1016     LPVOID buffer;
1017     HRESULT ret;
1018     DWORD size;
1019
1020     TRACE("(%s): relay\n", debugstr_w(srcfile));
1021
1022     if (!device || !srcfile || !defines)
1023         return D3DERR_INVALIDCALL;
1024
1025     ret = map_view_of_file(srcfile, &buffer, &size);
1026
1027     if (FAILED(ret))
1028         return D3DXERR_INVALIDDATA;
1029
1030     ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
1031     UnmapViewOfFile(buffer);
1032
1033     return ret;
1034 }
1035
1036 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
1037     const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
1038     LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
1039 {
1040     LPWSTR srcfileW;
1041     HRESULT ret;
1042     DWORD len;
1043
1044     TRACE("(void): relay\n");
1045
1046     if (!srcfile || !defines)
1047         return D3DERR_INVALIDCALL;
1048
1049     len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
1050     srcfileW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len * sizeof(WCHAR));
1051     MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
1052
1053     ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
1054     HeapFree(GetProcessHeap(), 0, srcfileW);
1055
1056     return ret;
1057 }
1058
1059 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
1060     const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
1061     LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
1062 {
1063     TRACE("(void): relay\n");
1064     return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
1065 }
1066
1067 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
1068     const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
1069     LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
1070 {
1071     TRACE("(void): relay\n");
1072     return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
1073 }
1074
1075 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
1076     const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
1077     LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
1078 {
1079     HRSRC resinfo;
1080
1081     TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
1082
1083     if (!device || !defines)
1084         return D3DERR_INVALIDCALL;
1085
1086     resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
1087
1088     if (resinfo)
1089     {
1090         LPVOID buffer;
1091         HRESULT ret;
1092         DWORD size;
1093
1094         ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
1095
1096         if (FAILED(ret))
1097             return D3DXERR_INVALIDDATA;
1098
1099         return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
1100     }
1101
1102     return D3DXERR_INVALIDDATA;
1103 }
1104
1105 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
1106     const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
1107     LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
1108 {
1109     HRSRC resinfo;
1110
1111     TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
1112
1113     if (!device || !defines)
1114         return D3DERR_INVALIDCALL;
1115
1116     resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
1117
1118     if (resinfo)
1119     {
1120         LPVOID buffer;
1121         HRESULT ret;
1122         DWORD size;
1123
1124         ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
1125
1126         if (FAILED(ret))
1127             return D3DXERR_INVALIDDATA;
1128
1129         return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
1130     }
1131
1132     return D3DXERR_INVALIDDATA;
1133 }
1134
1135 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
1136     const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
1137     LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
1138 {
1139     TRACE("(void): relay\n");
1140     return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
1141 }
1142
1143 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
1144     const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
1145     LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
1146 {
1147     TRACE("(void): relay\n");
1148     return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
1149 }
1150
1151 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
1152     DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
1153 {
1154     LPVOID buffer;
1155     HRESULT ret;
1156     DWORD size;
1157
1158     TRACE("(%s): relay\n", debugstr_w(srcfile));
1159
1160     if (!srcfile || !defines)
1161         return D3DERR_INVALIDCALL;
1162
1163     ret = map_view_of_file(srcfile, &buffer, &size);
1164
1165     if (FAILED(ret))
1166         return D3DXERR_INVALIDDATA;
1167
1168     ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
1169     UnmapViewOfFile(buffer);
1170
1171     return ret;
1172 }
1173
1174 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
1175     DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
1176 {
1177     LPWSTR srcfileW;
1178     HRESULT ret;
1179     DWORD len;
1180
1181     TRACE("(void): relay\n");
1182
1183     if (!srcfile || !defines)
1184         return D3DERR_INVALIDCALL;
1185
1186     len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
1187     srcfileW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len * sizeof(WCHAR));
1188     MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
1189
1190     ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
1191     HeapFree(GetProcessHeap(), 0, srcfileW);
1192
1193     return ret;
1194 }
1195
1196 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
1197     LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
1198 {
1199     HRSRC resinfo;
1200
1201     TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
1202
1203     resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
1204
1205     if (resinfo)
1206     {
1207         LPVOID buffer;
1208         HRESULT ret;
1209         DWORD size;
1210
1211         ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
1212
1213         if (FAILED(ret))
1214             return D3DXERR_INVALIDDATA;
1215
1216         return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
1217     }
1218
1219     return D3DXERR_INVALIDDATA;
1220 }
1221
1222 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
1223     LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
1224 {
1225     HRSRC resinfo;
1226
1227     TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
1228
1229     resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
1230
1231     if (resinfo)
1232     {
1233         LPVOID buffer;
1234         HRESULT ret;
1235         DWORD size;
1236
1237         ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
1238
1239         if (FAILED(ret))
1240             return D3DXERR_INVALIDDATA;
1241
1242         return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
1243     }
1244
1245     return D3DXERR_INVALIDDATA;
1246 }