d3dx9: Use size of variable instead of type.
[wine.git] / dlls / d3dx9_36 / effect.c
blob15683dfe7822852398ce671fc17b8e554c60b3f5
1 /*
2 * Copyright 2010 Christian Costa
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.
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.
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
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"
27 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
29 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl;
31 typedef struct ID3DXEffectImpl {
32 ID3DXEffect ID3DXEffect_iface;
33 LONG ref;
35 UINT parameter_count;
36 UINT technique_count;
37 } ID3DXEffectImpl;
39 static inline void read_dword(const char **ptr, DWORD *d)
41 memcpy(d, *ptr, sizeof(*d));
42 *ptr += sizeof(*d);
45 static void skip_dword_unknown(const char **ptr, unsigned int count)
47 unsigned int i;
48 DWORD d;
50 FIXME("Skipping %u unknown DWORDs:\n", count);
51 for (i = 0; i < count; ++i)
53 read_dword(ptr, &d);
54 FIXME("\t0x%08x\n", d);
58 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
60 return (0xfeff0000 | ((major) << 8) | (minor));
63 static inline ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
65 return CONTAINING_RECORD(iface, ID3DXEffectImpl, ID3DXEffect_iface);
68 /*** IUnknown methods ***/
69 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect* iface, REFIID riid, void** object)
71 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
73 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
75 if (IsEqualGUID(riid, &IID_IUnknown) ||
76 IsEqualGUID(riid, &IID_ID3DXBaseEffect) ||
77 IsEqualGUID(riid, &IID_ID3DXEffect))
79 This->ID3DXEffect_iface.lpVtbl->AddRef(iface);
80 *object = This;
81 return S_OK;
84 ERR("Interface %s not found\n", debugstr_guid(riid));
86 return E_NOINTERFACE;
89 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect* iface)
91 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
93 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
95 return InterlockedIncrement(&This->ref);
98 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect* iface)
100 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
101 ULONG ref = InterlockedDecrement(&This->ref);
103 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
105 if (!ref)
106 HeapFree(GetProcessHeap(), 0, This);
108 return ref;
111 /*** ID3DXBaseEffect methods ***/
112 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect* iface, D3DXEFFECT_DESC* desc)
114 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
116 FIXME("(%p)->(%p): stub\n", This, desc);
118 return E_NOTIMPL;
121 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC* desc)
123 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
125 FIXME("(%p)->(%p, %p): stub\n", This, parameter, desc);
127 return E_NOTIMPL;
130 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect* iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC* desc)
132 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
134 FIXME("(%p)->(%p, %p): stub\n", This, technique, desc);
136 return E_NOTIMPL;
139 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect* iface, D3DXHANDLE pass, D3DXPASS_DESC* desc)
141 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
143 FIXME("(%p)->(%p, %p): stub\n", This, pass, desc);
145 return E_NOTIMPL;
148 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect* iface, D3DXHANDLE shader, D3DXFUNCTION_DESC* desc)
150 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
152 FIXME("(%p)->(%p, %p): stub\n", This, shader, desc);
154 return E_NOTIMPL;
157 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect* iface, D3DXHANDLE parameter, UINT index)
159 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
161 FIXME("(%p)->(%p, %u): stub\n", This, parameter, index);
163 return NULL;
166 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect* iface, D3DXHANDLE parameter, LPCSTR name)
168 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
170 FIXME("(%p)->(%p, %s): stub\n", This, parameter, name);
172 return NULL;
175 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect* iface, D3DXHANDLE parameter, LPCSTR semantic)
177 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
179 FIXME("(%p)->(%p, %s): stub\n", This, parameter, semantic);
181 return NULL;
184 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect* iface, D3DXHANDLE parameter, UINT index)
186 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
188 FIXME("(%p)->(%p, %u): stub\n", This, parameter, index);
190 return NULL;
193 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect* iface, UINT index)
195 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
197 FIXME("(%p)->(%u): stub\n", This, index);
199 return NULL;
202 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect* iface, LPCSTR name)
204 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
206 FIXME("(%p)->(%s): stub\n", This, name);
208 return NULL;
211 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect* iface, D3DXHANDLE technique, UINT index)
213 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
215 FIXME("(%p)->(%p, %u): stub\n", This, technique, index);
217 return NULL;
220 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect* iface, D3DXHANDLE technique, LPCSTR name)
222 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
224 FIXME("(%p)->(%p, %s): stub\n", This, technique, name);
226 return NULL;
229 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect* iface, UINT index)
231 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
233 FIXME("(%p)->(%u): stub\n", This, index);
235 return NULL;
238 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect* iface, LPCSTR name)
240 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
242 FIXME("(%p)->(%s): stub\n", This, name);
244 return NULL;
247 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect* iface, D3DXHANDLE object, UINT index)
249 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
251 FIXME("(%p)->(%p, %u): stub\n", This, object, index);
253 return NULL;
256 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect* iface, D3DXHANDLE object, LPCSTR name)
258 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
260 FIXME("(%p)->(%p, %s): stub\n", This, object, name);
262 return NULL;
265 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
267 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
269 FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, data, bytes);
271 return E_NOTIMPL;
274 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
276 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
278 FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, data, bytes);
280 return E_NOTIMPL;
283 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect* iface, D3DXHANDLE parameter, BOOL b)
285 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
287 FIXME("(%p)->(%p, %u): stub\n", This, parameter, b);
289 return E_NOTIMPL;
292 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect* iface, D3DXHANDLE parameter, BOOL* b)
294 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
296 FIXME("(%p)->(%p, %p): stub\n", This, parameter, b);
298 return E_NOTIMPL;
301 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect* iface, D3DXHANDLE parameter, CONST BOOL* b, UINT count)
303 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
305 FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, b, count);
307 return E_NOTIMPL;
310 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect* iface, D3DXHANDLE parameter, BOOL* b, UINT count)
312 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
314 FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, b, count);
316 return E_NOTIMPL;
319 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect* iface, D3DXHANDLE parameter, INT n)
321 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
323 FIXME("(%p)->(%p, %d): stub\n", This, parameter, n);
325 return E_NOTIMPL;
328 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect* iface, D3DXHANDLE parameter, INT* n)
330 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
332 FIXME("(%p)->(%p, %p): stub\n", This, parameter, n);
334 return E_NOTIMPL;
337 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect* iface, D3DXHANDLE parameter, CONST INT* n, UINT count)
339 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
341 FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, n, count);
343 return E_NOTIMPL;
346 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect* iface, D3DXHANDLE parameter, INT* n, UINT count)
348 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
350 FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, n, count);
352 return E_NOTIMPL;
355 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect* iface, D3DXHANDLE parameter, FLOAT f)
357 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
359 FIXME("(%p)->(%p, %f): stub\n", This, parameter, f);
361 return E_NOTIMPL;
364 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect* iface, D3DXHANDLE parameter, FLOAT* f)
366 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
368 FIXME("(%p)->(%p, %p): stub\n", This, parameter, f);
370 return E_NOTIMPL;
373 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect* iface, D3DXHANDLE parameter, CONST FLOAT* f, UINT count)
375 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
377 FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, f, count);
379 return E_NOTIMPL;
382 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect* iface, D3DXHANDLE parameter, FLOAT* f, UINT count)
384 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
386 FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, f, count);
388 return E_NOTIMPL;
391 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect* iface, D3DXHANDLE parameter, CONST D3DXVECTOR4* vector)
393 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
395 FIXME("(%p)->(%p, %p): stub\n", This, parameter, vector);
397 return E_NOTIMPL;
400 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXVECTOR4* vector)
402 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
404 FIXME("(%p)->(%p, %p): stub\n", This, parameter, vector);
406 return E_NOTIMPL;
409 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect* iface, D3DXHANDLE parameter, CONST D3DXVECTOR4* vector, UINT count)
411 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
413 FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, vector, count);
415 return E_NOTIMPL;
418 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXVECTOR4* vector, UINT count)
420 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
422 FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, vector, count);
424 return E_NOTIMPL;
427 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect* iface, D3DXHANDLE parameter, CONST D3DXMATRIX* matrix)
429 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
431 FIXME("(%p)->(%p, %p): stub\n", This, parameter, matrix);
433 return E_NOTIMPL;
436 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXMATRIX* matrix)
438 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
440 FIXME("(%p)->(%p, %p): stub\n", This, parameter, matrix);
442 return E_NOTIMPL;
445 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect* iface, D3DXHANDLE parameter, CONST D3DXMATRIX* matrix, UINT count)
447 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
449 FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, matrix, count);
451 return E_NOTIMPL;
454 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXMATRIX* matrix, UINT count)
456 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
458 FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, matrix, count);
460 return E_NOTIMPL;
463 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect* iface, D3DXHANDLE parameter, CONST D3DXMATRIX** matrix, UINT count)
465 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
467 FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, matrix, count);
469 return E_NOTIMPL;
472 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXMATRIX** matrix, UINT count)
474 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
476 FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, matrix, count);
478 return E_NOTIMPL;
481 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect* iface, D3DXHANDLE parameter, CONST D3DXMATRIX* matrix)
483 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
485 FIXME("(%p)->(%p, %p): stub\n", This, parameter, matrix);
487 return E_NOTIMPL;
490 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXMATRIX* matrix)
492 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
494 FIXME("(%p)->(%p, %p): stub\n", This, parameter, matrix);
496 return E_NOTIMPL;
499 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect* iface, D3DXHANDLE parameter, CONST D3DXMATRIX* matrix, UINT count)
501 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
503 FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, matrix, count);
505 return E_NOTIMPL;
508 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXMATRIX* matrix, UINT count)
510 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
512 FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, matrix, count);
514 return E_NOTIMPL;
517 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect* iface, D3DXHANDLE parameter, CONST D3DXMATRIX** matrix, UINT count)
519 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
521 FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, matrix, count);
523 return E_NOTIMPL;
526 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXMATRIX** matrix, UINT count)
528 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
530 FIXME("(%p)->(%p, %p, %u): stub\n", This, parameter, matrix, count);
532 return E_NOTIMPL;
535 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect* iface, D3DXHANDLE parameter, LPCSTR string)
537 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
539 FIXME("(%p)->(%p, %p): stub\n", This, parameter, string);
541 return E_NOTIMPL;
544 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect* iface, D3DXHANDLE parameter, LPCSTR* string)
546 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
548 FIXME("(%p)->(%p, %p): stub\n", This, parameter, string);
550 return E_NOTIMPL;
553 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect* iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
555 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
557 FIXME("(%p)->(%p, %p): stub\n", This, parameter, texture);
559 return E_NOTIMPL;
562 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect* iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9* texture)
564 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
566 FIXME("(%p)->(%p, %p): stub\n", This, parameter, texture);
568 return E_NOTIMPL;
571 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect* iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9* pshader)
573 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
575 FIXME("(%p)->(%p, %p): stub\n", This, parameter, pshader);
577 return E_NOTIMPL;
580 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect* iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9* vshader)
582 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
584 FIXME("(%p)->(%p, %p): stub\n", This, parameter, vshader);
586 return E_NOTIMPL;
589 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect* iface, D3DXHANDLE parameter, UINT start, UINT end)
591 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
593 FIXME("(%p)->(%p, %u, %u): stub\n", This, parameter, start, end);
595 return E_NOTIMPL;
598 /*** ID3DXEffect methods ***/
599 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect* iface, LPD3DXEFFECTPOOL* pool)
601 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
603 FIXME("(%p)->(%p): stub\n", This, pool);
605 return E_NOTIMPL;
608 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
610 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
612 FIXME("(%p)->(%p): stub\n", This, technique);
614 return E_NOTIMPL;
617 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect* iface)
619 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
621 FIXME("(%p)->(): stub\n", This);
623 return NULL;
626 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
628 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
630 FIXME("(%p)->(%p): stub\n", This, technique);
632 return D3D_OK;
635 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
637 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
639 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
641 return E_NOTIMPL;
644 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
646 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
648 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
650 return FALSE;
653 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect* iface, UINT *passes, DWORD flags)
655 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
657 FIXME("(%p)->(%p, %#x): stub\n", This, passes, flags);
659 return E_NOTIMPL;
662 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect* iface, UINT pass)
664 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
666 FIXME("(%p)->(%u): stub\n", This, pass);
668 return E_NOTIMPL;
671 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
673 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
675 FIXME("(%p)->(): stub\n", This);
677 return E_NOTIMPL;
680 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect* iface)
682 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
684 FIXME("(%p)->(): stub\n", This);
686 return E_NOTIMPL;
689 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
691 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
693 FIXME("(%p)->(): stub\n", This);
695 return E_NOTIMPL;
698 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect* iface, LPDIRECT3DDEVICE9* device)
700 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
702 FIXME("(%p)->(%p): stub\n", This, device);
704 return E_NOTIMPL;
707 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
709 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
711 FIXME("(%p)->(): stub\n", This);
713 return E_NOTIMPL;
716 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
718 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
720 FIXME("(%p)->(): stub\n", This);
722 return E_NOTIMPL;
725 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect* iface, LPD3DXEFFECTSTATEMANAGER manager)
727 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
729 FIXME("(%p)->(%p): stub\n", This, manager);
731 return E_NOTIMPL;
734 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect* iface, LPD3DXEFFECTSTATEMANAGER* manager)
736 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
738 FIXME("(%p)->(%p): stub\n", This, manager);
740 return E_NOTIMPL;
743 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
745 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
747 FIXME("(%p)->(): stub\n", This);
749 return E_NOTIMPL;
752 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
754 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
756 FIXME("(%p)->(): stub\n", This);
758 return NULL;
761 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
763 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
765 FIXME("(%p)->(%p): stub\n", This, parameter_block);
767 return E_NOTIMPL;
770 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
772 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
774 FIXME("(%p)->(%p): stub\n", This, parameter_block);
776 return E_NOTIMPL;
779 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
781 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
783 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
785 return E_NOTIMPL;
788 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
790 ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
792 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
794 return E_NOTIMPL;
797 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
799 /*** IUnknown methods ***/
800 ID3DXEffectImpl_QueryInterface,
801 ID3DXEffectImpl_AddRef,
802 ID3DXEffectImpl_Release,
803 /*** ID3DXBaseEffect methods ***/
804 ID3DXEffectImpl_GetDesc,
805 ID3DXEffectImpl_GetParameterDesc,
806 ID3DXEffectImpl_GetTechniqueDesc,
807 ID3DXEffectImpl_GetPassDesc,
808 ID3DXEffectImpl_GetFunctionDesc,
809 ID3DXEffectImpl_GetParameter,
810 ID3DXEffectImpl_GetParameterByName,
811 ID3DXEffectImpl_GetParameterBySemantic,
812 ID3DXEffectImpl_GetParameterElement,
813 ID3DXEffectImpl_GetTechnique,
814 ID3DXEffectImpl_GetTechniqueByName,
815 ID3DXEffectImpl_GetPass,
816 ID3DXEffectImpl_GetPassByName,
817 ID3DXEffectImpl_GetFunction,
818 ID3DXEffectImpl_GetFunctionByName,
819 ID3DXEffectImpl_GetAnnotation,
820 ID3DXEffectImpl_GetAnnotationByName,
821 ID3DXEffectImpl_SetValue,
822 ID3DXEffectImpl_GetValue,
823 ID3DXEffectImpl_SetBool,
824 ID3DXEffectImpl_GetBool,
825 ID3DXEffectImpl_SetBoolArray,
826 ID3DXEffectImpl_GetBoolArray,
827 ID3DXEffectImpl_SetInt,
828 ID3DXEffectImpl_GetInt,
829 ID3DXEffectImpl_SetIntArray,
830 ID3DXEffectImpl_GetIntArray,
831 ID3DXEffectImpl_SetFloat,
832 ID3DXEffectImpl_GetFloat,
833 ID3DXEffectImpl_SetFloatArray,
834 ID3DXEffectImpl_GetFloatArray,
835 ID3DXEffectImpl_SetVector,
836 ID3DXEffectImpl_GetVector,
837 ID3DXEffectImpl_SetVectorArray,
838 ID3DXEffectImpl_GetVectorArray,
839 ID3DXEffectImpl_SetMatrix,
840 ID3DXEffectImpl_GetMatrix,
841 ID3DXEffectImpl_SetMatrixArray,
842 ID3DXEffectImpl_GetMatrixArray,
843 ID3DXEffectImpl_SetMatrixPointerArray,
844 ID3DXEffectImpl_GetMatrixPointerArray,
845 ID3DXEffectImpl_SetMatrixTranspose,
846 ID3DXEffectImpl_GetMatrixTranspose,
847 ID3DXEffectImpl_SetMatrixTransposeArray,
848 ID3DXEffectImpl_GetMatrixTransposeArray,
849 ID3DXEffectImpl_SetMatrixTransposePointerArray,
850 ID3DXEffectImpl_GetMatrixTransposePointerArray,
851 ID3DXEffectImpl_SetString,
852 ID3DXEffectImpl_GetString,
853 ID3DXEffectImpl_SetTexture,
854 ID3DXEffectImpl_GetTexture,
855 ID3DXEffectImpl_GetPixelShader,
856 ID3DXEffectImpl_GetVertexShader,
857 ID3DXEffectImpl_SetArrayRange,
858 /*** ID3DXEffect methods ***/
859 ID3DXEffectImpl_GetPool,
860 ID3DXEffectImpl_SetTechnique,
861 ID3DXEffectImpl_GetCurrentTechnique,
862 ID3DXEffectImpl_ValidateTechnique,
863 ID3DXEffectImpl_FindNextValidTechnique,
864 ID3DXEffectImpl_IsParameterUsed,
865 ID3DXEffectImpl_Begin,
866 ID3DXEffectImpl_BeginPass,
867 ID3DXEffectImpl_CommitChanges,
868 ID3DXEffectImpl_EndPass,
869 ID3DXEffectImpl_End,
870 ID3DXEffectImpl_GetDevice,
871 ID3DXEffectImpl_OnLostDevice,
872 ID3DXEffectImpl_OnResetDevice,
873 ID3DXEffectImpl_SetStateManager,
874 ID3DXEffectImpl_GetStateManager,
875 ID3DXEffectImpl_BeginParameterBlock,
876 ID3DXEffectImpl_EndParameterBlock,
877 ID3DXEffectImpl_ApplyParameterBlock,
878 ID3DXEffectImpl_DeleteParameterBlock,
879 ID3DXEffectImpl_CloneEffect,
880 ID3DXEffectImpl_SetRawValue
883 static HRESULT d3dx9_parse_effect(ID3DXEffectImpl *effect, const char *data, UINT data_size, DWORD start)
885 const char *ptr = data + start;
887 read_dword(&ptr, &effect->parameter_count);
888 TRACE("Parameter count: %u\n", effect->parameter_count);
890 read_dword(&ptr, &effect->technique_count);
891 TRACE("Technique count: %u\n", effect->technique_count);
893 skip_dword_unknown(&ptr, 2);
895 /* todo: Parse parameter */
897 /* todo: Parse techniques */
899 return S_OK;
902 static HRESULT d3dx9_effect_init(ID3DXEffectImpl *effect, const char *data, SIZE_T data_size)
904 DWORD tag, offset;
905 const char *ptr = data;
906 HRESULT hr;
908 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
909 effect->ref = 1;
911 read_dword(&ptr, &tag);
912 TRACE("Tag: %x\n", tag);
914 if (tag != d3dx9_effect_version(9, 1))
916 /* todo: compile hlsl ascii code */
917 FIXME("HLSL ascii effects not supported, yet\n");
919 /* Show the start of the shader for debugging info. */
920 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
922 else
924 read_dword(&ptr, &offset);
925 TRACE("Offset: %x\n", offset);
927 hr = d3dx9_parse_effect(effect, ptr, data_size, offset);
928 if (hr != S_OK)
930 FIXME("Failed to parse effect.\n");
931 return hr;
935 return S_OK;
938 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
939 LPCVOID srcdata,
940 UINT srcdatalen,
941 CONST D3DXMACRO* defines,
942 LPD3DXINCLUDE include,
943 LPCSTR skip_constants,
944 DWORD flags,
945 LPD3DXEFFECTPOOL pool,
946 LPD3DXEFFECT* effect,
947 LPD3DXBUFFER* compilation_errors)
949 ID3DXEffectImpl *object;
950 HRESULT hr;
952 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
953 skip_constants, flags, pool, effect, compilation_errors);
955 if (!device || !srcdata)
956 return D3DERR_INVALIDCALL;
958 if (!srcdatalen)
959 return E_FAIL;
961 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
962 if (!effect)
963 return D3D_OK;
965 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
966 if (!object)
968 ERR("Out of memory\n");
969 return E_OUTOFMEMORY;
972 hr = d3dx9_effect_init(object, srcdata, srcdatalen);
973 if (FAILED(hr))
975 WARN("Failed to initialize shader reflection\n");
976 HeapFree(GetProcessHeap(), 0, object);
977 return hr;
980 *effect = &object->ID3DXEffect_iface;
982 TRACE("Created ID3DXEffect %p\n", object);
984 return D3D_OK;
987 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
988 LPCVOID srcdata,
989 UINT srcdatalen,
990 CONST D3DXMACRO* defines,
991 LPD3DXINCLUDE include,
992 DWORD flags,
993 LPD3DXEFFECTPOOL pool,
994 LPD3DXEFFECT* effect,
995 LPD3DXBUFFER* compilation_errors)
997 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
998 include, flags, pool, effect, compilation_errors);
1000 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
1003 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
1004 UINT srcdatalen,
1005 CONST D3DXMACRO* defines,
1006 LPD3DXINCLUDE include,
1007 DWORD flags,
1008 LPD3DXEFFECTCOMPILER* compiler,
1009 LPD3DXBUFFER* parse_errors)
1011 FIXME("(%p, %u, %p, %p, %#x, %p, %p): stub\n", srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
1013 return E_NOTIMPL;
1016 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
1018 typedef struct ID3DXEffectPoolImpl {
1019 ID3DXEffectPool ID3DXEffectPool_iface;
1020 LONG ref;
1021 } ID3DXEffectPoolImpl;
1023 static inline ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
1025 return CONTAINING_RECORD(iface, ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
1028 /*** IUnknown methods ***/
1029 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool* iface, REFIID riid, void** object)
1031 ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
1033 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
1035 if (IsEqualGUID(riid, &IID_IUnknown) ||
1036 IsEqualGUID(riid, &IID_ID3DXEffectPool))
1038 This->ID3DXEffectPool_iface.lpVtbl->AddRef(iface);
1039 *object = This;
1040 return S_OK;
1043 WARN("Interface %s not found\n", debugstr_guid(riid));
1045 return E_NOINTERFACE;
1048 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool* iface)
1050 ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
1052 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
1054 return InterlockedIncrement(&This->ref);
1057 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool* iface)
1059 ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
1060 ULONG ref = InterlockedDecrement(&This->ref);
1062 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
1064 if (!ref)
1065 HeapFree(GetProcessHeap(), 0, This);
1067 return ref;
1070 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
1072 /*** IUnknown methods ***/
1073 ID3DXEffectPoolImpl_QueryInterface,
1074 ID3DXEffectPoolImpl_AddRef,
1075 ID3DXEffectPoolImpl_Release
1078 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL* pool)
1080 ID3DXEffectPoolImpl* object;
1082 TRACE("(%p)\n", pool);
1084 if (!pool)
1085 return D3DERR_INVALIDCALL;
1087 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1088 if (!object)
1090 ERR("Out of memory\n");
1091 return E_OUTOFMEMORY;
1094 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
1095 object->ref = 1;
1097 *pool = &object->ID3DXEffectPool_iface;
1099 return S_OK;
1102 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
1103 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
1104 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
1106 LPVOID buffer;
1107 HRESULT ret;
1108 DWORD size;
1110 TRACE("(%s): relay\n", debugstr_w(srcfile));
1112 if (!device || !srcfile || !defines)
1113 return D3DERR_INVALIDCALL;
1115 ret = map_view_of_file(srcfile, &buffer, &size);
1117 if (FAILED(ret))
1118 return D3DXERR_INVALIDDATA;
1120 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
1121 UnmapViewOfFile(buffer);
1123 return ret;
1126 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
1127 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
1128 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
1130 LPWSTR srcfileW;
1131 HRESULT ret;
1132 DWORD len;
1134 TRACE("(void): relay\n");
1136 if (!srcfile || !defines)
1137 return D3DERR_INVALIDCALL;
1139 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
1140 srcfileW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len * sizeof(*srcfileW));
1141 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
1143 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
1144 HeapFree(GetProcessHeap(), 0, srcfileW);
1146 return ret;
1149 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
1150 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
1151 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
1153 TRACE("(void): relay\n");
1154 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
1157 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
1158 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
1159 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
1161 TRACE("(void): relay\n");
1162 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
1165 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
1166 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
1167 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
1169 HRSRC resinfo;
1171 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
1173 if (!device || !defines)
1174 return D3DERR_INVALIDCALL;
1176 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
1178 if (resinfo)
1180 LPVOID buffer;
1181 HRESULT ret;
1182 DWORD size;
1184 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
1186 if (FAILED(ret))
1187 return D3DXERR_INVALIDDATA;
1189 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
1192 return D3DXERR_INVALIDDATA;
1195 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
1196 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
1197 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
1199 HRSRC resinfo;
1201 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
1203 if (!device || !defines)
1204 return D3DERR_INVALIDCALL;
1206 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
1208 if (resinfo)
1210 LPVOID buffer;
1211 HRESULT ret;
1212 DWORD size;
1214 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
1216 if (FAILED(ret))
1217 return D3DXERR_INVALIDDATA;
1219 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
1222 return D3DXERR_INVALIDDATA;
1225 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
1226 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
1227 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
1229 TRACE("(void): relay\n");
1230 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
1233 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
1234 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
1235 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
1237 TRACE("(void): relay\n");
1238 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
1241 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
1242 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
1244 LPVOID buffer;
1245 HRESULT ret;
1246 DWORD size;
1248 TRACE("(%s): relay\n", debugstr_w(srcfile));
1250 if (!srcfile || !defines)
1251 return D3DERR_INVALIDCALL;
1253 ret = map_view_of_file(srcfile, &buffer, &size);
1255 if (FAILED(ret))
1256 return D3DXERR_INVALIDDATA;
1258 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
1259 UnmapViewOfFile(buffer);
1261 return ret;
1264 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
1265 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
1267 LPWSTR srcfileW;
1268 HRESULT ret;
1269 DWORD len;
1271 TRACE("(void): relay\n");
1273 if (!srcfile || !defines)
1274 return D3DERR_INVALIDCALL;
1276 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
1277 srcfileW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len * sizeof(*srcfileW));
1278 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
1280 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
1281 HeapFree(GetProcessHeap(), 0, srcfileW);
1283 return ret;
1286 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
1287 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
1289 HRSRC resinfo;
1291 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
1293 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
1295 if (resinfo)
1297 LPVOID buffer;
1298 HRESULT ret;
1299 DWORD size;
1301 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
1303 if (FAILED(ret))
1304 return D3DXERR_INVALIDDATA;
1306 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
1309 return D3DXERR_INVALIDDATA;
1312 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
1313 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
1315 HRSRC resinfo;
1317 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
1319 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
1321 if (resinfo)
1323 LPVOID buffer;
1324 HRESULT ret;
1325 DWORD size;
1327 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
1329 if (FAILED(ret))
1330 return D3DXERR_INVALIDDATA;
1332 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
1335 return D3DXERR_INVALIDDATA;