d3dx9: Implement ID3DXBaseEffect::GetInt().
[wine/multimedia.git] / dlls / d3dx9_36 / effect.c
blobc7ad93bd8b699611529397ad9f408ef936f60a5b
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;
30 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl;
31 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl;
33 struct d3dx_parameter
35 struct ID3DXBaseEffectImpl *base;
37 char *name;
38 char *semantic;
39 void *data;
40 D3DXPARAMETER_CLASS class;
41 D3DXPARAMETER_TYPE type;
42 UINT rows;
43 UINT columns;
44 UINT element_count;
45 UINT annotation_count;
46 UINT member_count;
47 DWORD flags;
48 UINT bytes;
50 D3DXHANDLE *annotation_handles;
51 D3DXHANDLE *member_handles;
54 struct d3dx_pass
56 struct ID3DXBaseEffectImpl *base;
58 char *name;
59 UINT state_count;
60 UINT annotation_count;
62 D3DXHANDLE *annotation_handles;
65 struct d3dx_technique
67 struct ID3DXBaseEffectImpl *base;
69 char *name;
70 UINT pass_count;
71 UINT annotation_count;
73 D3DXHANDLE *annotation_handles;
74 D3DXHANDLE *pass_handles;
77 struct ID3DXBaseEffectImpl
79 ID3DXBaseEffect ID3DXBaseEffect_iface;
80 LONG ref;
82 struct ID3DXEffectImpl *effect;
84 UINT parameter_count;
85 UINT technique_count;
86 UINT object_count;
88 D3DXHANDLE *parameter_handles;
89 D3DXHANDLE *technique_handles;
90 D3DXHANDLE *objects;
93 struct ID3DXEffectImpl
95 ID3DXEffect ID3DXEffect_iface;
96 LONG ref;
98 LPDIRECT3DDEVICE9 device;
99 LPD3DXEFFECTPOOL pool;
101 ID3DXBaseEffect *base_effect;
104 struct ID3DXEffectCompilerImpl
106 ID3DXEffectCompiler ID3DXEffectCompiler_iface;
107 LONG ref;
109 ID3DXBaseEffect *base_effect;
112 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
113 struct d3dx_parameter *parameter, LPCSTR name);
114 static struct d3dx_parameter *get_parameter_annotation_by_name(struct ID3DXBaseEffectImpl *base,
115 struct d3dx_parameter *parameter, LPCSTR name);
117 static inline void read_dword(const char **ptr, DWORD *d)
119 memcpy(d, *ptr, sizeof(*d));
120 *ptr += sizeof(*d);
123 static void skip_dword_unknown(const char **ptr, unsigned int count)
125 unsigned int i;
126 DWORD d;
128 FIXME("Skipping %u unknown DWORDs:\n", count);
129 for (i = 0; i < count; ++i)
131 read_dword(ptr, &d);
132 FIXME("\t0x%08x\n", d);
136 static inline struct d3dx_parameter *get_parameter_struct(D3DXHANDLE handle)
138 return (struct d3dx_parameter *) handle;
141 static inline struct d3dx_pass *get_pass_struct(D3DXHANDLE handle)
143 return (struct d3dx_pass *) handle;
146 static inline struct d3dx_technique *get_technique_struct(D3DXHANDLE handle)
148 return (struct d3dx_technique *) handle;
151 static inline D3DXHANDLE get_parameter_handle(struct d3dx_parameter *parameter)
153 return (D3DXHANDLE) parameter;
156 static inline D3DXHANDLE get_technique_handle(struct d3dx_technique *technique)
158 return (D3DXHANDLE) technique;
161 static inline D3DXHANDLE get_pass_handle(struct d3dx_pass *pass)
163 return (D3DXHANDLE) pass;
166 static struct d3dx_technique *is_valid_technique(struct ID3DXBaseEffectImpl *base, D3DXHANDLE technique)
168 unsigned int i;
170 for (i = 0; i < base->technique_count; ++i)
172 if (base->technique_handles[i] == technique)
174 return get_technique_struct(technique);
178 return NULL;
181 static struct d3dx_pass *is_valid_pass(struct ID3DXBaseEffectImpl *base, D3DXHANDLE pass)
183 unsigned int i, k;
185 for (i = 0; i < base->technique_count; ++i)
187 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
189 for (k = 0; k < technique->pass_count; ++k)
191 if (technique->pass_handles[k] == pass)
193 return get_pass_struct(pass);
198 return NULL;
201 static struct d3dx_parameter *is_valid_sub_parameter(struct d3dx_parameter *param, D3DXHANDLE parameter)
203 unsigned int i, count;
204 struct d3dx_parameter *p;
206 for (i = 0; i < param->annotation_count; ++i)
208 if (param->annotation_handles[i] == parameter)
210 return get_parameter_struct(parameter);
213 p = is_valid_sub_parameter(get_parameter_struct(param->annotation_handles[i]), parameter);
214 if (p) return p;
217 if (param->element_count) count = param->element_count;
218 else count = param->member_count;
220 for (i = 0; i < count; ++i)
222 if (param->member_handles[i] == parameter)
224 return get_parameter_struct(parameter);
227 p = is_valid_sub_parameter(get_parameter_struct(param->member_handles[i]), parameter);
228 if (p) return p;
231 return NULL;
234 static struct d3dx_parameter *is_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter)
236 unsigned int i, k, m;
237 struct d3dx_parameter *p;
239 for (i = 0; i < base->parameter_count; ++i)
241 if (base->parameter_handles[i] == parameter)
243 return get_parameter_struct(parameter);
246 p = is_valid_sub_parameter(get_parameter_struct(base->parameter_handles[i]), parameter);
247 if (p) return p;
250 for (i = 0; i < base->technique_count; ++i)
252 struct d3dx_technique *technique = get_technique_struct(base->technique_handles[i]);
254 for (k = 0; k < technique->pass_count; ++k)
256 struct d3dx_pass *pass = get_pass_struct(technique->pass_handles[k]);
258 for (m = 0; m < pass->annotation_count; ++m)
260 if (pass->annotation_handles[i] == parameter)
262 return get_parameter_struct(parameter);
265 p = is_valid_sub_parameter(get_parameter_struct(pass->annotation_handles[m]), parameter);
266 if (p) return p;
270 for (k = 0; k < technique->annotation_count; ++k)
272 if (technique->annotation_handles[k] == parameter)
274 return get_parameter_struct(parameter);
277 p = is_valid_sub_parameter(get_parameter_struct(technique->annotation_handles[k]), parameter);
278 if (p) return p;
282 return NULL;
285 static void free_parameter(D3DXHANDLE handle, BOOL element, BOOL child)
287 unsigned int i;
288 struct d3dx_parameter *param = get_parameter_struct(handle);
290 TRACE("Free parameter %p, child %s\n", param, child ? "yes" : "no");
292 if (!param)
294 return;
297 if (param->annotation_handles)
299 for (i = 0; i < param->annotation_count; ++i)
301 free_parameter(param->annotation_handles[i], FALSE, FALSE);
303 HeapFree(GetProcessHeap(), 0, param->annotation_handles);
306 if (param->member_handles)
308 unsigned int count;
310 if (param->element_count) count = param->element_count;
311 else count = param->member_count;
313 for (i = 0; i < count; ++i)
315 free_parameter(param->member_handles[i], param->element_count != 0, TRUE);
317 HeapFree(GetProcessHeap(), 0, param->member_handles);
320 if (param->class == D3DXPC_OBJECT && !param->element_count)
322 switch(param->type)
324 case D3DXPT_STRING:
325 HeapFree(GetProcessHeap(), 0, *(LPSTR *)param->data);
326 break;
328 case D3DXPT_PIXELSHADER:
329 case D3DXPT_VERTEXSHADER:
330 if (*(IUnknown **)param->data) IUnknown_Release(*(IUnknown **)param->data);
331 break;
333 default:
334 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
335 break;
339 if (!child)
341 HeapFree(GetProcessHeap(), 0, param->data);
344 /* only the parent has to release name and semantic */
345 if (!element)
347 HeapFree(GetProcessHeap(), 0, param->name);
348 HeapFree(GetProcessHeap(), 0, param->semantic);
351 HeapFree(GetProcessHeap(), 0, param);
354 static void free_pass(D3DXHANDLE handle)
356 unsigned int i;
357 struct d3dx_pass *pass = get_pass_struct(handle);
359 TRACE("Free pass %p\n", pass);
361 if (!pass)
363 return;
366 if (pass->annotation_handles)
368 for (i = 0; i < pass->annotation_count; ++i)
370 free_parameter(pass->annotation_handles[i], FALSE, FALSE);
372 HeapFree(GetProcessHeap(), 0, pass->annotation_handles);
375 HeapFree(GetProcessHeap(), 0, pass->name);
376 HeapFree(GetProcessHeap(), 0, pass);
379 static void free_technique(D3DXHANDLE handle)
381 unsigned int i;
382 struct d3dx_technique *technique = get_technique_struct(handle);
384 TRACE("Free technique %p\n", technique);
386 if (!technique)
388 return;
391 if (technique->annotation_handles)
393 for (i = 0; i < technique->annotation_count; ++i)
395 free_parameter(technique->annotation_handles[i], FALSE, FALSE);
397 HeapFree(GetProcessHeap(), 0, technique->annotation_handles);
400 if (technique->pass_handles)
402 for (i = 0; i < technique->pass_count; ++i)
404 free_pass(technique->pass_handles[i]);
406 HeapFree(GetProcessHeap(), 0, technique->pass_handles);
409 HeapFree(GetProcessHeap(), 0, technique->name);
410 HeapFree(GetProcessHeap(), 0, technique);
413 static void free_base_effect(struct ID3DXBaseEffectImpl *base)
415 unsigned int i;
417 TRACE("Free base effect %p\n", base);
419 if (base->parameter_handles)
421 for (i = 0; i < base->parameter_count; ++i)
423 free_parameter(base->parameter_handles[i], FALSE, FALSE);
425 HeapFree(GetProcessHeap(), 0, base->parameter_handles);
428 if (base->technique_handles)
430 for (i = 0; i < base->technique_count; ++i)
432 free_technique(base->technique_handles[i]);
434 HeapFree(GetProcessHeap(), 0, base->technique_handles);
438 static void free_effect(struct ID3DXEffectImpl *effect)
440 TRACE("Free effect %p\n", effect);
442 if (effect->base_effect)
444 effect->base_effect->lpVtbl->Release(effect->base_effect);
447 if (effect->pool)
449 effect->pool->lpVtbl->Release(effect->pool);
452 IDirect3DDevice9_Release(effect->device);
455 static void free_effect_compiler(struct ID3DXEffectCompilerImpl *compiler)
457 TRACE("Free effect compiler %p\n", compiler);
459 if (compiler->base_effect)
461 compiler->base_effect->lpVtbl->Release(compiler->base_effect);
465 static INT get_int(D3DXPARAMETER_TYPE type, void *data)
467 INT i;
469 switch (type)
471 case D3DXPT_FLOAT:
472 i = *(FLOAT *)data;
473 break;
475 case D3DXPT_INT:
476 i = *(INT *)data;
477 break;
479 case D3DXPT_BOOL:
480 i = *(BOOL *)data;
481 break;
483 default:
484 i = 0;
485 FIXME("Unhandled type %s. This should not happen!\n", debug_d3dxparameter_type(type));
486 break;
489 return i;
492 static inline BOOL get_bool(void *data)
494 return (*(DWORD *)data) ? TRUE : FALSE;
497 static struct d3dx_parameter *get_parameter_element_by_name(struct ID3DXBaseEffectImpl *base,
498 struct d3dx_parameter *parameter, LPCSTR name)
500 UINT element;
501 struct d3dx_parameter *temp_parameter;
502 LPCSTR part;
504 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
506 if (!name || !*name) return parameter;
508 element = atoi(name);
509 part = strchr(name, ']') + 1;
511 if (parameter->element_count > element)
513 temp_parameter = get_parameter_struct(parameter->member_handles[element]);
515 switch (*part++)
517 case '.':
518 return get_parameter_by_name(base, temp_parameter, part);
520 case '@':
521 return get_parameter_annotation_by_name(base, temp_parameter, part);
523 case '\0':
524 TRACE("Returning parameter %p\n", temp_parameter);
525 return temp_parameter;
527 default:
528 FIXME("Unhandled case \"%c\"\n", *--part);
529 break;
533 TRACE("Parameter not found\n");
534 return NULL;
537 static struct d3dx_parameter *get_parameter_annotation_by_name(struct ID3DXBaseEffectImpl *base,
538 struct d3dx_parameter *parameter, LPCSTR name)
540 UINT i, length;
541 struct d3dx_parameter *temp_parameter;
542 LPCSTR part;
544 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
546 if (!name || !*name) return parameter;
548 length = strcspn( name, "[.@" );
549 part = name + length;
551 for (i = 0; i < parameter->annotation_count; ++i)
553 temp_parameter = get_parameter_struct(parameter->annotation_handles[i]);
555 if (!strcmp(temp_parameter->name, name))
557 TRACE("Returning parameter %p\n", temp_parameter);
558 return temp_parameter;
560 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
562 switch (*part++)
564 case '.':
565 return get_parameter_by_name(base, temp_parameter, part);
567 case '[':
568 return get_parameter_element_by_name(base, temp_parameter, part);
570 default:
571 FIXME("Unhandled case \"%c\"\n", *--part);
572 break;
577 TRACE("Parameter not found\n");
578 return NULL;
581 static struct d3dx_parameter *get_parameter_by_name(struct ID3DXBaseEffectImpl *base,
582 struct d3dx_parameter *parameter, LPCSTR name)
584 UINT i, count, length;
585 struct d3dx_parameter *temp_parameter;
586 D3DXHANDLE *handles;
587 LPCSTR part;
589 TRACE("base %p, parameter %p, name %s\n", base, parameter, debugstr_a(name));
591 if (!name || !*name) return parameter;
593 if (!parameter)
595 count = base->parameter_count;
596 handles = base->parameter_handles;
598 else
600 count = parameter->member_count;
601 handles = parameter->member_handles;
604 length = strcspn( name, "[.@" );
605 part = name + length;
607 for (i = 0; i < count; i++)
609 temp_parameter = get_parameter_struct(handles[i]);
611 if (!strcmp(temp_parameter->name, name))
613 TRACE("Returning parameter %p\n", temp_parameter);
614 return temp_parameter;
616 else if (strlen(temp_parameter->name) == length && !strncmp(temp_parameter->name, name, length))
618 switch (*part++)
620 case '.':
621 return get_parameter_by_name(base, temp_parameter, part);
623 case '@':
624 return get_parameter_annotation_by_name(base, temp_parameter, part);
626 case '[':
627 return get_parameter_element_by_name(base, temp_parameter, part);
629 default:
630 FIXME("Unhandled case \"%c\"\n", *--part);
631 break;
636 TRACE("Parameter not found\n");
637 return NULL;
640 static inline DWORD d3dx9_effect_version(DWORD major, DWORD minor)
642 return (0xfeff0000 | ((major) << 8) | (minor));
645 static inline struct ID3DXBaseEffectImpl *impl_from_ID3DXBaseEffect(ID3DXBaseEffect *iface)
647 return CONTAINING_RECORD(iface, struct ID3DXBaseEffectImpl, ID3DXBaseEffect_iface);
650 /*** IUnknown methods ***/
651 static HRESULT WINAPI ID3DXBaseEffectImpl_QueryInterface(ID3DXBaseEffect *iface, REFIID riid, void **object)
653 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
655 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
657 if (IsEqualGUID(riid, &IID_IUnknown) ||
658 IsEqualGUID(riid, &IID_ID3DXBaseEffect))
660 This->ID3DXBaseEffect_iface.lpVtbl->AddRef(iface);
661 *object = This;
662 return S_OK;
665 ERR("Interface %s not found\n", debugstr_guid(riid));
667 return E_NOINTERFACE;
670 static ULONG WINAPI ID3DXBaseEffectImpl_AddRef(ID3DXBaseEffect *iface)
672 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
674 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
676 return InterlockedIncrement(&This->ref);
679 static ULONG WINAPI ID3DXBaseEffectImpl_Release(ID3DXBaseEffect *iface)
681 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
682 ULONG ref = InterlockedDecrement(&This->ref);
684 TRACE("iface %p: Release from %u\n", iface, ref + 1);
686 if (!ref)
688 free_base_effect(This);
689 HeapFree(GetProcessHeap(), 0, This);
692 return ref;
695 /*** ID3DXBaseEffect methods ***/
696 static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEFFECT_DESC *desc)
698 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
700 FIXME("iface %p, desc %p partial stub\n", This, desc);
702 if (!desc)
704 WARN("Invalid argument specified.\n");
705 return D3DERR_INVALIDCALL;
708 /* Todo: add creator and function count */
709 desc->Creator = NULL;
710 desc->Functions = 0;
711 desc->Parameters = This->parameter_count;
712 desc->Techniques = This->technique_count;
714 return D3D_OK;
717 static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
719 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
720 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
722 TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc);
724 if (!param) param = get_parameter_struct(iface->lpVtbl->GetParameterByName(iface, NULL, parameter));
726 if (!desc || !param)
728 WARN("Invalid argument specified.\n");
729 return D3DERR_INVALIDCALL;
732 desc->Name = param->name;
733 desc->Semantic = param->semantic;
734 desc->Class = param->class;
735 desc->Type = param->type;
736 desc->Rows = param->rows;
737 desc->Columns = param->columns;
738 desc->Elements = param->element_count;
739 desc->Annotations = param->annotation_count;
740 desc->StructMembers = param->member_count;
741 desc->Flags = param->flags;
742 desc->Bytes = param->bytes;
744 return D3D_OK;
747 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTechniqueDesc(ID3DXBaseEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
749 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
750 struct d3dx_technique *tech = technique ? is_valid_technique(This, technique) : get_technique_struct(This->technique_handles[0]);
752 TRACE("iface %p, technique %p, desc %p\n", This, technique, desc);
754 if (!desc || !tech)
756 WARN("Invalid argument specified.\n");
757 return D3DERR_INVALIDCALL;
760 desc->Name = tech->name;
761 desc->Passes = tech->pass_count;
762 desc->Annotations = tech->annotation_count;
764 return D3D_OK;
767 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPassDesc(ID3DXBaseEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
769 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
770 struct d3dx_pass *p = is_valid_pass(This, pass);
772 TRACE("iface %p, pass %p, desc %p\n", This, pass, desc);
774 if (!desc || !p)
776 WARN("Invalid argument specified.\n");
777 return D3DERR_INVALIDCALL;
780 desc->Name = p->name;
781 desc->Annotations = p->annotation_count;
783 FIXME("Pixel shader and vertex shader are not supported, yet.\n");
784 desc->pVertexShaderFunction = NULL;
785 desc->pVertexShaderFunction = NULL;
787 return D3D_OK;
790 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
792 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
794 FIXME("iface %p, shader %p, desc %p stub\n", This, shader, desc);
796 return E_NOTIMPL;
799 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
801 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
802 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
804 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
806 if (!param) param = get_parameter_by_name(This, NULL, parameter);
808 if (!parameter)
810 if (index < This->parameter_count)
812 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
813 return This->parameter_handles[index];
816 else
818 if (param && !param->element_count && index < param->member_count)
820 TRACE("Returning parameter %p\n", param->member_handles[index]);
821 return param->member_handles[index];
825 WARN("Invalid argument specified.\n");
827 return NULL;
830 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name)
832 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
833 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
834 D3DXHANDLE handle;
836 TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name));
838 if (!param) param = get_parameter_by_name(This, NULL, parameter);
840 if (!name)
842 handle = get_parameter_handle(param);
843 TRACE("Returning parameter %p\n", handle);
844 return handle;
847 handle = get_parameter_handle(get_parameter_by_name(This, param, name));
848 TRACE("Returning parameter %p\n", handle);
850 return handle;
853 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
855 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
856 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
857 struct d3dx_parameter *temp_param;
858 UINT i;
860 TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic));
862 if (!param) param = get_parameter_by_name(This, NULL, parameter);
864 if (!parameter)
866 for (i = 0; i < This->parameter_count; ++i)
868 temp_param = get_parameter_struct(This->parameter_handles[i]);
870 if (!temp_param->semantic)
872 if (!semantic)
874 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
875 return This->parameter_handles[i];
877 continue;
880 if (!strcasecmp(temp_param->semantic, semantic))
882 TRACE("Returning parameter %p\n", This->parameter_handles[i]);
883 return This->parameter_handles[i];
887 else if (param)
889 for (i = 0; i < param->member_count; ++i)
891 temp_param = get_parameter_struct(param->member_handles[i]);
893 if (!temp_param->semantic)
895 if (!semantic)
897 TRACE("Returning parameter %p\n", param->member_handles[i]);
898 return param->member_handles[i];
900 continue;
903 if (!strcasecmp(temp_param->semantic, semantic))
905 TRACE("Returning parameter %p\n", param->member_handles[i]);
906 return param->member_handles[i];
911 WARN("Invalid argument specified\n");
913 return NULL;
916 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index)
918 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
919 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
921 TRACE("iface %p, parameter %p, index %u\n", This, parameter, index);
923 if (!param) param = get_parameter_by_name(This, NULL, parameter);
925 if (!param)
927 if (index < This->parameter_count)
929 TRACE("Returning parameter %p\n", This->parameter_handles[index]);
930 return This->parameter_handles[index];
933 else
935 if (index < param->element_count)
937 TRACE("Returning parameter %p\n", param->member_handles[index]);
938 return param->member_handles[index];
942 WARN("Invalid argument specified\n");
944 return NULL;
947 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechnique(ID3DXBaseEffect *iface, UINT index)
949 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
951 TRACE("iface %p, index %u\n", This, index);
953 if (index >= This->technique_count)
955 WARN("Invalid argument specified.\n");
956 return NULL;
959 TRACE("Returning technique %p\n", This->technique_handles[index]);
961 return This->technique_handles[index];
964 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetTechniqueByName(ID3DXBaseEffect *iface, LPCSTR name)
966 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
967 unsigned int i;
969 TRACE("iface %p, name %s stub\n", This, debugstr_a(name));
971 if (!name)
973 WARN("Invalid argument specified.\n");
974 return NULL;
977 for (i = 0; i < This->technique_count; ++i)
979 struct d3dx_technique *tech = get_technique_struct(This->technique_handles[i]);
981 if (!strcmp(tech->name, name))
983 TRACE("Returning technique %p\n", This->technique_handles[i]);
984 return This->technique_handles[i];
988 WARN("Invalid argument specified.\n");
990 return NULL;
993 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPass(ID3DXBaseEffect *iface, D3DXHANDLE technique, UINT index)
995 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
996 struct d3dx_technique *tech = is_valid_technique(This, technique);
998 TRACE("iface %p, technique %p, index %u\n", This, technique, index);
1000 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1002 if (tech && index < tech->pass_count)
1004 TRACE("Returning pass %p\n", tech->pass_handles[index]);
1005 return tech->pass_handles[index];
1008 WARN("Invalid argument specified.\n");
1010 return NULL;
1013 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetPassByName(ID3DXBaseEffect *iface, D3DXHANDLE technique, LPCSTR name)
1015 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1016 struct d3dx_technique *tech = is_valid_technique(This, technique);
1018 TRACE("iface %p, technique %p, name %s\n", This, technique, debugstr_a(name));
1020 if (!tech) tech = get_technique_struct(iface->lpVtbl->GetTechniqueByName(iface, technique));
1022 if (tech && name)
1024 unsigned int i;
1026 for (i = 0; i < tech->pass_count; ++i)
1028 struct d3dx_pass *pass = get_pass_struct(tech->pass_handles[i]);
1030 if (!strcmp(pass->name, name))
1032 TRACE("Returning pass %p\n", tech->pass_handles[i]);
1033 return tech->pass_handles[i];
1038 WARN("Invalid argument specified.\n");
1040 return NULL;
1043 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunction(ID3DXBaseEffect *iface, UINT index)
1045 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1047 FIXME("iface %p, index %u stub\n", This, index);
1049 return NULL;
1052 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect *iface, LPCSTR name)
1054 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1056 FIXME("iface %p, name %s stub\n", This, debugstr_a(name));
1058 return NULL;
1061 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index)
1063 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1064 struct d3dx_parameter *param = is_valid_parameter(This, object);
1065 struct d3dx_pass *pass = is_valid_pass(This, object);
1066 struct d3dx_technique *technique = is_valid_technique(This, object);
1067 UINT annotation_count = 0;
1068 D3DXHANDLE *annotation_handles = NULL;
1070 FIXME("iface %p, object %p, index %u partial stub\n", This, object, index);
1072 if (pass)
1074 annotation_count = pass->annotation_count;
1075 annotation_handles = pass->annotation_handles;
1077 else if (technique)
1079 annotation_count = technique->annotation_count;
1080 annotation_handles = technique->annotation_handles;
1082 else
1084 if (!param) param = get_parameter_by_name(This, NULL, object);
1086 if (param)
1088 annotation_count = param->annotation_count;
1089 annotation_handles = param->annotation_handles;
1092 /* Todo: add funcs */
1094 if (index < annotation_count)
1096 TRACE("Returning parameter %p\n", annotation_handles[index]);
1097 return annotation_handles[index];
1100 WARN("Invalid argument specified\n");
1102 return NULL;
1105 static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name)
1107 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1108 struct d3dx_parameter *param = is_valid_parameter(This, object);
1109 struct d3dx_pass *pass = is_valid_pass(This, object);
1110 struct d3dx_technique *technique = is_valid_technique(This, object);
1111 UINT annotation_count = 0, i;
1112 D3DXHANDLE *annotation_handles = NULL;
1114 FIXME("iface %p, object %p, name %s partial stub\n", This, object, debugstr_a(name));
1116 if (!name)
1118 WARN("Invalid argument specified\n");
1119 return NULL;
1122 if (pass)
1124 annotation_count = pass->annotation_count;
1125 annotation_handles = pass->annotation_handles;
1127 else if (technique)
1129 annotation_count = technique->annotation_count;
1130 annotation_handles = technique->annotation_handles;
1132 else
1134 if (!param) param = get_parameter_by_name(This, NULL, object);
1136 if (param)
1138 annotation_count = param->annotation_count;
1139 annotation_handles = param->annotation_handles;
1142 /* Todo: add funcs */
1144 for (i = 0; i < annotation_count; i++)
1146 struct d3dx_parameter *anno = get_parameter_struct(annotation_handles[i]);
1148 if (!strcmp(anno->name, name))
1150 TRACE("Returning parameter %p\n", anno);
1151 return get_parameter_handle(anno);
1155 WARN("Invalid argument specified\n");
1157 return NULL;
1160 static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1162 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1164 FIXME("iface %p, parameter %p, data %p, bytes %u stub\n", This, parameter, data, bytes);
1166 return E_NOTIMPL;
1169 static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1171 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1172 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1174 TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes);
1176 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1178 if (data && param && param->data && param->bytes <= bytes)
1180 if (param->type == D3DXPT_VERTEXSHADER || param->type == D3DXPT_PIXELSHADER)
1182 UINT i;
1184 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
1186 IUnknown *unk = ((IUnknown **)param->data)[i];
1187 if (unk) IUnknown_AddRef(unk);
1188 ((IUnknown **)data)[i] = unk;
1191 else
1193 TRACE("Copy %u bytes\n", param->bytes);
1194 memcpy(data, param->data, param->bytes);
1196 return D3D_OK;
1199 WARN("Invalid argument specified\n");
1201 return D3DERR_INVALIDCALL;
1204 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL b)
1206 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1208 FIXME("iface %p, parameter %p, b %u stub\n", This, parameter, b);
1210 return E_NOTIMPL;
1213 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b)
1215 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1216 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1218 TRACE("iface %p, parameter %p, b %p\n", This, parameter, b);
1220 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1222 if (b && param && !param->element_count && param->class == D3DXPC_SCALAR)
1224 *b = get_bool(param->data);
1225 TRACE("Returning %s\n", *b ? "TRUE" : "FALSE");
1226 return D3D_OK;
1229 WARN("Invalid argument specified\n");
1231 return D3DERR_INVALIDCALL;
1234 static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1236 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1238 FIXME("iface %p, parameter %p, b %p, count %u stub\n", This, parameter, b, count);
1240 return E_NOTIMPL;
1243 static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1245 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1247 FIXME("iface %p, parameter %p, b %p, count %u stub\n", This, parameter, b, count);
1249 return E_NOTIMPL;
1252 static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT n)
1254 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1256 FIXME("iface %p, parameter %p, n %u stub\n", This, parameter, n);
1258 return E_NOTIMPL;
1261 static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n)
1263 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1264 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1266 TRACE("iface %p, parameter %p, n %p\n", This, parameter, n);
1268 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1270 if (n && param && !param->element_count && param->class == D3DXPC_SCALAR)
1272 *n = get_int(param->type, param->data);
1273 TRACE("Returning %i\n", *n);
1274 return D3D_OK;
1277 WARN("Invalid argument specified\n");
1279 return D3DERR_INVALIDCALL;
1282 static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1284 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1286 FIXME("iface %p, parameter %p, n %p, count %u stub\n", This, parameter, n, count);
1288 return E_NOTIMPL;
1291 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1293 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1295 FIXME("iface %p, parameter %p, n %p, count %u stub\n", This, parameter, n, count);
1297 return E_NOTIMPL;
1300 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT f)
1302 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1304 FIXME("iface %p, parameter %p, f %f stub\n", This, parameter, f);
1306 return E_NOTIMPL;
1309 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1311 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1313 FIXME("iface %p, parameter %p, f %p stub\n", This, parameter, f);
1315 return E_NOTIMPL;
1318 static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
1320 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1322 FIXME("iface %p, parameter %p, f %p, count %u stub\n", This, parameter, f, count);
1324 return E_NOTIMPL;
1327 static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
1329 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1331 FIXME("iface %p, parameter %p, f %p, count %u stub\n", This, parameter, f, count);
1333 return E_NOTIMPL;
1336 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVector(ID3DXBaseEffect* iface, D3DXHANDLE parameter, CONST D3DXVECTOR4* vector)
1338 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1340 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1342 return E_NOTIMPL;
1345 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVector(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
1347 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1349 FIXME("iface %p, parameter %p, vector %p stub\n", This, parameter, vector);
1351 return E_NOTIMPL;
1354 static HRESULT WINAPI ID3DXBaseEffectImpl_SetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
1356 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1358 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1360 return E_NOTIMPL;
1363 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVectorArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
1365 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1367 FIXME("iface %p, parameter %p, vector %p, count %u stub\n", This, parameter, vector, count);
1369 return E_NOTIMPL;
1372 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1374 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1376 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1378 return E_NOTIMPL;
1381 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrix(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1383 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1385 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1387 return E_NOTIMPL;
1390 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1392 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1394 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1396 return E_NOTIMPL;
1399 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1401 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1403 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1405 return E_NOTIMPL;
1408 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1410 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1412 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1414 return E_NOTIMPL;
1417 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixPointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1419 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1421 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1423 return E_NOTIMPL;
1426 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
1428 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1430 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1432 return E_NOTIMPL;
1435 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTranspose(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
1437 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1439 FIXME("iface %p, parameter %p, matrix %p stub\n", This, parameter, matrix);
1441 return E_NOTIMPL;
1444 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
1446 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1448 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1450 return E_NOTIMPL;
1453 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposeArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
1455 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1457 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1459 return E_NOTIMPL;
1462 static HRESULT WINAPI ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
1464 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1466 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1468 return E_NOTIMPL;
1471 static HRESULT WINAPI ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
1473 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1475 FIXME("iface %p, parameter %p, matrix %p, count %u stub\n", This, parameter, matrix, count);
1477 return E_NOTIMPL;
1480 static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR string)
1482 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1484 FIXME("iface %p, parameter %p, string %p stub\n", This, parameter, string);
1486 return E_NOTIMPL;
1489 static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
1491 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1492 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1494 TRACE("iface %p, parameter %p, string %p\n", This, parameter, string);
1496 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1498 if (string && param && !param->element_count && param->type == D3DXPT_STRING)
1500 *string = *(LPCSTR *)param->data;
1501 TRACE("Returning %s\n", debugstr_a(*string));
1502 return D3D_OK;
1505 WARN("Invalid argument specified\n");
1507 return D3DERR_INVALIDCALL;
1510 static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
1512 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1514 FIXME("iface %p, parameter %p, texture %p stub\n", This, parameter, texture);
1516 return E_NOTIMPL;
1519 static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
1521 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1523 FIXME("iface %p, parameter %p, texture %p stub\n", This, parameter, texture);
1525 return E_NOTIMPL;
1528 static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
1530 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1531 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1533 TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader);
1535 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1537 if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER)
1539 *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data;
1540 if (*pshader) IDirect3DPixelShader9_AddRef(*pshader);
1541 TRACE("Returning %p\n", *pshader);
1542 return D3D_OK;
1545 WARN("Invalid argument specified\n");
1547 return D3DERR_INVALIDCALL;
1550 static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
1552 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1553 struct d3dx_parameter *param = is_valid_parameter(This, parameter);
1555 TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader);
1557 if (!param) param = get_parameter_by_name(This, NULL, parameter);
1559 if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER)
1561 *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;
1562 if (*vshader) IDirect3DVertexShader9_AddRef(*vshader);
1563 TRACE("Returning %p\n", *vshader);
1564 return D3D_OK;
1567 WARN("Invalid argument specified\n");
1569 return D3DERR_INVALIDCALL;
1572 static HRESULT WINAPI ID3DXBaseEffectImpl_SetArrayRange(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
1574 struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface);
1576 FIXME("iface %p, parameter %p, start %u, end %u stub\n", This, parameter, start, end);
1578 return E_NOTIMPL;
1581 static const struct ID3DXBaseEffectVtbl ID3DXBaseEffect_Vtbl =
1583 /*** IUnknown methods ***/
1584 ID3DXBaseEffectImpl_QueryInterface,
1585 ID3DXBaseEffectImpl_AddRef,
1586 ID3DXBaseEffectImpl_Release,
1587 /*** ID3DXBaseEffect methods ***/
1588 ID3DXBaseEffectImpl_GetDesc,
1589 ID3DXBaseEffectImpl_GetParameterDesc,
1590 ID3DXBaseEffectImpl_GetTechniqueDesc,
1591 ID3DXBaseEffectImpl_GetPassDesc,
1592 ID3DXBaseEffectImpl_GetFunctionDesc,
1593 ID3DXBaseEffectImpl_GetParameter,
1594 ID3DXBaseEffectImpl_GetParameterByName,
1595 ID3DXBaseEffectImpl_GetParameterBySemantic,
1596 ID3DXBaseEffectImpl_GetParameterElement,
1597 ID3DXBaseEffectImpl_GetTechnique,
1598 ID3DXBaseEffectImpl_GetTechniqueByName,
1599 ID3DXBaseEffectImpl_GetPass,
1600 ID3DXBaseEffectImpl_GetPassByName,
1601 ID3DXBaseEffectImpl_GetFunction,
1602 ID3DXBaseEffectImpl_GetFunctionByName,
1603 ID3DXBaseEffectImpl_GetAnnotation,
1604 ID3DXBaseEffectImpl_GetAnnotationByName,
1605 ID3DXBaseEffectImpl_SetValue,
1606 ID3DXBaseEffectImpl_GetValue,
1607 ID3DXBaseEffectImpl_SetBool,
1608 ID3DXBaseEffectImpl_GetBool,
1609 ID3DXBaseEffectImpl_SetBoolArray,
1610 ID3DXBaseEffectImpl_GetBoolArray,
1611 ID3DXBaseEffectImpl_SetInt,
1612 ID3DXBaseEffectImpl_GetInt,
1613 ID3DXBaseEffectImpl_SetIntArray,
1614 ID3DXBaseEffectImpl_GetIntArray,
1615 ID3DXBaseEffectImpl_SetFloat,
1616 ID3DXBaseEffectImpl_GetFloat,
1617 ID3DXBaseEffectImpl_SetFloatArray,
1618 ID3DXBaseEffectImpl_GetFloatArray,
1619 ID3DXBaseEffectImpl_SetVector,
1620 ID3DXBaseEffectImpl_GetVector,
1621 ID3DXBaseEffectImpl_SetVectorArray,
1622 ID3DXBaseEffectImpl_GetVectorArray,
1623 ID3DXBaseEffectImpl_SetMatrix,
1624 ID3DXBaseEffectImpl_GetMatrix,
1625 ID3DXBaseEffectImpl_SetMatrixArray,
1626 ID3DXBaseEffectImpl_GetMatrixArray,
1627 ID3DXBaseEffectImpl_SetMatrixPointerArray,
1628 ID3DXBaseEffectImpl_GetMatrixPointerArray,
1629 ID3DXBaseEffectImpl_SetMatrixTranspose,
1630 ID3DXBaseEffectImpl_GetMatrixTranspose,
1631 ID3DXBaseEffectImpl_SetMatrixTransposeArray,
1632 ID3DXBaseEffectImpl_GetMatrixTransposeArray,
1633 ID3DXBaseEffectImpl_SetMatrixTransposePointerArray,
1634 ID3DXBaseEffectImpl_GetMatrixTransposePointerArray,
1635 ID3DXBaseEffectImpl_SetString,
1636 ID3DXBaseEffectImpl_GetString,
1637 ID3DXBaseEffectImpl_SetTexture,
1638 ID3DXBaseEffectImpl_GetTexture,
1639 ID3DXBaseEffectImpl_GetPixelShader,
1640 ID3DXBaseEffectImpl_GetVertexShader,
1641 ID3DXBaseEffectImpl_SetArrayRange,
1644 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
1646 return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
1649 /*** IUnknown methods ***/
1650 static HRESULT WINAPI ID3DXEffectImpl_QueryInterface(ID3DXEffect *iface, REFIID riid, void **object)
1652 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1654 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
1656 if (IsEqualGUID(riid, &IID_IUnknown) ||
1657 IsEqualGUID(riid, &IID_ID3DXEffect))
1659 This->ID3DXEffect_iface.lpVtbl->AddRef(iface);
1660 *object = This;
1661 return S_OK;
1664 ERR("Interface %s not found\n", debugstr_guid(riid));
1666 return E_NOINTERFACE;
1669 static ULONG WINAPI ID3DXEffectImpl_AddRef(ID3DXEffect *iface)
1671 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1673 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
1675 return InterlockedIncrement(&This->ref);
1678 static ULONG WINAPI ID3DXEffectImpl_Release(ID3DXEffect *iface)
1680 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1681 ULONG ref = InterlockedDecrement(&This->ref);
1683 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
1685 if (!ref)
1687 free_effect(This);
1688 HeapFree(GetProcessHeap(), 0, This);
1691 return ref;
1694 /*** ID3DXBaseEffect methods ***/
1695 static HRESULT WINAPI ID3DXEffectImpl_GetDesc(ID3DXEffect *iface, D3DXEFFECT_DESC *desc)
1697 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1698 ID3DXBaseEffect *base = This->base_effect;
1700 TRACE("Forward iface %p, base %p\n", This, base);
1702 return ID3DXBaseEffectImpl_GetDesc(base, desc);
1705 static HRESULT WINAPI ID3DXEffectImpl_GetParameterDesc(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
1707 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1708 ID3DXBaseEffect *base = This->base_effect;
1710 TRACE("Forward iface %p, base %p\n", This, base);
1712 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
1715 static HRESULT WINAPI ID3DXEffectImpl_GetTechniqueDesc(ID3DXEffect *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
1717 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1718 ID3DXBaseEffect *base = This->base_effect;
1720 TRACE("Forward iface %p, base %p\n", This, base);
1722 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
1725 static HRESULT WINAPI ID3DXEffectImpl_GetPassDesc(ID3DXEffect *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
1727 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1728 ID3DXBaseEffect *base = This->base_effect;
1730 TRACE("Forward iface %p, base %p\n", This, base);
1732 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
1735 static HRESULT WINAPI ID3DXEffectImpl_GetFunctionDesc(ID3DXEffect *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
1737 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1738 ID3DXBaseEffect *base = This->base_effect;
1740 TRACE("Forward iface %p, base %p\n", This, base);
1742 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
1745 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameter(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
1747 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1748 ID3DXBaseEffect *base = This->base_effect;
1750 TRACE("Forward iface %p, base %p\n", This, base);
1752 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
1755 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterByName(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR name)
1757 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1758 ID3DXBaseEffect *base = This->base_effect;
1760 TRACE("Forward iface %p, base %p\n", This, base);
1762 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
1765 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterBySemantic(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR semantic)
1767 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1768 ID3DXBaseEffect *base = This->base_effect;
1770 TRACE("Forward iface %p, base %p\n", This, base);
1772 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
1775 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetParameterElement(ID3DXEffect *iface, D3DXHANDLE parameter, UINT index)
1777 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1778 ID3DXBaseEffect *base = This->base_effect;
1780 TRACE("Forward iface %p, base %p\n", This, base);
1782 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
1785 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechnique(ID3DXEffect *iface, UINT index)
1787 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1788 ID3DXBaseEffect *base = This->base_effect;
1790 TRACE("Forward iface %p, base %p\n", This, base);
1792 return ID3DXBaseEffectImpl_GetTechnique(base, index);
1795 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetTechniqueByName(ID3DXEffect *iface, LPCSTR name)
1797 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1798 ID3DXBaseEffect *base = This->base_effect;
1800 TRACE("Forward iface %p, base %p\n", This, base);
1802 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
1805 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPass(ID3DXEffect *iface, D3DXHANDLE technique, UINT index)
1807 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1808 ID3DXBaseEffect *base = This->base_effect;
1810 TRACE("Forward iface %p, base %p\n", This, base);
1812 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
1815 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetPassByName(ID3DXEffect *iface, D3DXHANDLE technique, LPCSTR name)
1817 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1818 ID3DXBaseEffect *base = This->base_effect;
1820 TRACE("Forward iface %p, base %p\n", This, base);
1822 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
1825 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunction(ID3DXEffect *iface, UINT index)
1827 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1828 ID3DXBaseEffect *base = This->base_effect;
1830 TRACE("Forward iface %p, base %p\n", This, base);
1832 return ID3DXBaseEffectImpl_GetFunction(base, index);
1835 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetFunctionByName(ID3DXEffect *iface, LPCSTR name)
1837 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1838 ID3DXBaseEffect *base = This->base_effect;
1840 TRACE("Forward iface %p, base %p\n", This, base);
1842 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
1845 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotation(ID3DXEffect *iface, D3DXHANDLE object, UINT index)
1847 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1848 ID3DXBaseEffect *base = This->base_effect;
1850 TRACE("Forward iface %p, base %p\n", This, base);
1852 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
1855 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetAnnotationByName(ID3DXEffect *iface, D3DXHANDLE object, LPCSTR name)
1857 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1858 ID3DXBaseEffect *base = This->base_effect;
1860 TRACE("Forward iface %p, base %p\n", This, base);
1862 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
1865 static HRESULT WINAPI ID3DXEffectImpl_SetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
1867 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1868 ID3DXBaseEffect *base = This->base_effect;
1870 TRACE("Forward iface %p, base %p\n", This, base);
1872 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
1875 static HRESULT WINAPI ID3DXEffectImpl_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
1877 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1878 ID3DXBaseEffect *base = This->base_effect;
1880 TRACE("Forward iface %p, base %p\n", This, base);
1882 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
1885 static HRESULT WINAPI ID3DXEffectImpl_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
1887 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1888 ID3DXBaseEffect *base = This->base_effect;
1890 TRACE("Forward iface %p, base %p\n", This, base);
1892 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
1895 static HRESULT WINAPI ID3DXEffectImpl_GetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b)
1897 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1898 ID3DXBaseEffect *base = This->base_effect;
1900 TRACE("Forward iface %p, base %p\n", This, base);
1902 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
1905 static HRESULT WINAPI ID3DXEffectImpl_SetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
1907 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1908 ID3DXBaseEffect *base = This->base_effect;
1910 TRACE("Forward iface %p, base %p\n", This, base);
1912 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
1915 static HRESULT WINAPI ID3DXEffectImpl_GetBoolArray(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
1917 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1918 ID3DXBaseEffect *base = This->base_effect;
1920 TRACE("Forward iface %p, base %p\n", This, base);
1922 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
1925 static HRESULT WINAPI ID3DXEffectImpl_SetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT n)
1927 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1928 ID3DXBaseEffect *base = This->base_effect;
1930 TRACE("Forward iface %p, base %p\n", This, base);
1932 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
1935 static HRESULT WINAPI ID3DXEffectImpl_GetInt(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n)
1937 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1938 ID3DXBaseEffect *base = This->base_effect;
1940 TRACE("Forward iface %p, base %p\n", This, base);
1942 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
1945 static HRESULT WINAPI ID3DXEffectImpl_SetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
1947 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1948 ID3DXBaseEffect *base = This->base_effect;
1950 TRACE("Forward iface %p, base %p\n", This, base);
1952 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
1955 static HRESULT WINAPI ID3DXEffectImpl_GetIntArray(ID3DXEffect *iface, D3DXHANDLE parameter, INT *n, UINT count)
1957 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1958 ID3DXBaseEffect *base = This->base_effect;
1960 TRACE("Forward iface %p, base %p\n", This, base);
1962 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
1965 static HRESULT WINAPI ID3DXEffectImpl_SetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT f)
1967 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1968 ID3DXBaseEffect *base = This->base_effect;
1970 TRACE("Forward iface %p, base %p\n", This, base);
1972 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
1975 static HRESULT WINAPI ID3DXEffectImpl_GetFloat(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f)
1977 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1978 ID3DXBaseEffect *base = This->base_effect;
1980 TRACE("Forward iface %p, base %p\n", This, base);
1982 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
1985 static HRESULT WINAPI ID3DXEffectImpl_SetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
1987 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1988 ID3DXBaseEffect *base = This->base_effect;
1990 TRACE("Forward iface %p, base %p\n", This, base);
1992 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
1995 static HRESULT WINAPI ID3DXEffectImpl_GetFloatArray(ID3DXEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
1997 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
1998 ID3DXBaseEffect *base = This->base_effect;
2000 TRACE("Forward iface %p, base %p\n", This, base);
2002 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2005 static HRESULT WINAPI ID3DXEffectImpl_SetVector(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2007 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2008 ID3DXBaseEffect *base = This->base_effect;
2010 TRACE("Forward iface %p, base %p\n", This, base);
2012 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2015 static HRESULT WINAPI ID3DXEffectImpl_GetVector(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2017 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2018 ID3DXBaseEffect *base = This->base_effect;
2020 TRACE("Forward iface %p, base %p\n", This, base);
2022 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
2025 static HRESULT WINAPI ID3DXEffectImpl_SetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2027 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2028 ID3DXBaseEffect *base = This->base_effect;
2030 TRACE("Forward iface %p, base %p\n", This, base);
2032 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
2035 static HRESULT WINAPI ID3DXEffectImpl_GetVectorArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2037 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2038 ID3DXBaseEffect *base = This->base_effect;
2040 TRACE("Forward iface %p, base %p\n", This, base);
2042 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
2045 static HRESULT WINAPI ID3DXEffectImpl_SetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2047 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2048 ID3DXBaseEffect *base = This->base_effect;
2050 TRACE("Forward iface %p, base %p\n", This, base);
2052 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
2055 static HRESULT WINAPI ID3DXEffectImpl_GetMatrix(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2057 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2058 ID3DXBaseEffect *base = This->base_effect;
2060 TRACE("Forward iface %p, base %p\n", This, base);
2062 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
2065 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2067 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2068 ID3DXBaseEffect *base = This->base_effect;
2070 TRACE("Forward iface %p, base %p\n", This, base);
2072 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
2075 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2077 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2078 ID3DXBaseEffect *base = This->base_effect;
2080 TRACE("Forward iface %p, base %p\n", This, base);
2082 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
2085 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2087 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2088 ID3DXBaseEffect *base = This->base_effect;
2090 TRACE("Forward iface %p, base %p\n", This, base);
2092 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
2095 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixPointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2097 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2098 ID3DXBaseEffect *base = This->base_effect;
2100 TRACE("Forward iface %p, base %p\n", This, base);
2102 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
2105 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2107 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2108 ID3DXBaseEffect *base = This->base_effect;
2110 TRACE("Forward iface %p, base %p\n", This, base);
2112 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
2115 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTranspose(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2117 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2118 ID3DXBaseEffect *base = This->base_effect;
2120 TRACE("Forward iface %p, base %p\n", This, base);
2122 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
2125 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2127 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2128 ID3DXBaseEffect *base = This->base_effect;
2130 TRACE("Forward iface %p, base %p\n", This, base);
2132 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
2135 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposeArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2137 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2138 ID3DXBaseEffect *base = This->base_effect;
2140 TRACE("Forward iface %p, base %p\n", This, base);
2142 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
2145 static HRESULT WINAPI ID3DXEffectImpl_SetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2147 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2148 ID3DXBaseEffect *base = This->base_effect;
2150 TRACE("Forward iface %p, base %p\n", This, base);
2152 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
2155 static HRESULT WINAPI ID3DXEffectImpl_GetMatrixTransposePointerArray(ID3DXEffect *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
2157 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2158 ID3DXBaseEffect *base = This->base_effect;
2160 TRACE("Forward iface %p, base %p\n", This, base);
2162 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
2165 static HRESULT WINAPI ID3DXEffectImpl_SetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR string)
2167 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2168 ID3DXBaseEffect *base = This->base_effect;
2170 TRACE("Forward iface %p, base %p\n", This, base);
2172 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
2175 static HRESULT WINAPI ID3DXEffectImpl_GetString(ID3DXEffect *iface, D3DXHANDLE parameter, LPCSTR *string)
2177 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2178 ID3DXBaseEffect *base = This->base_effect;
2180 TRACE("Forward iface %p, base %p\n", This, base);
2182 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
2185 static HRESULT WINAPI ID3DXEffectImpl_SetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
2187 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2188 ID3DXBaseEffect *base = This->base_effect;
2190 TRACE("Forward iface %p, base %p\n", This, base);
2192 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
2195 static HRESULT WINAPI ID3DXEffectImpl_GetTexture(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
2197 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2198 ID3DXBaseEffect *base = This->base_effect;
2200 TRACE("Forward iface %p, base %p\n", This, base);
2202 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
2205 static HRESULT WINAPI ID3DXEffectImpl_GetPixelShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
2207 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2208 ID3DXBaseEffect *base = This->base_effect;
2210 TRACE("Forward iface %p, base %p\n", This, base);
2212 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
2215 static HRESULT WINAPI ID3DXEffectImpl_GetVertexShader(ID3DXEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
2217 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2218 ID3DXBaseEffect *base = This->base_effect;
2220 TRACE("Forward iface %p, base %p\n", This, base);
2222 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
2225 static HRESULT WINAPI ID3DXEffectImpl_SetArrayRange(ID3DXEffect *iface, D3DXHANDLE parameter, UINT start, UINT end)
2227 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2228 ID3DXBaseEffect *base = This->base_effect;
2230 TRACE("Forward iface %p, base %p\n", This, base);
2232 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
2235 /*** ID3DXEffect methods ***/
2236 static HRESULT WINAPI ID3DXEffectImpl_GetPool(ID3DXEffect *iface, LPD3DXEFFECTPOOL *pool)
2238 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2240 TRACE("iface %p, pool %p\n", This, pool);
2242 if (!pool)
2244 WARN("Invalid argument supplied.\n");
2245 return D3DERR_INVALIDCALL;
2248 if (This->pool)
2250 This->pool->lpVtbl->AddRef(This->pool);
2253 *pool = This->pool;
2255 TRACE("Returning pool %p\n", *pool);
2257 return S_OK;
2260 static HRESULT WINAPI ID3DXEffectImpl_SetTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2262 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2264 FIXME("(%p)->(%p): stub\n", This, technique);
2266 return E_NOTIMPL;
2269 static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect* iface)
2271 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2273 FIXME("(%p)->(): stub\n", This);
2275 return NULL;
2278 static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique)
2280 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2282 FIXME("(%p)->(%p): stub\n", This, technique);
2284 return D3D_OK;
2287 static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique)
2289 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2291 FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique);
2293 return E_NOTIMPL;
2296 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
2298 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2300 FIXME("(%p)->(%p, %p): stub\n", This, parameter, technique);
2302 return FALSE;
2305 static HRESULT WINAPI ID3DXEffectImpl_Begin(ID3DXEffect* iface, UINT *passes, DWORD flags)
2307 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2309 FIXME("(%p)->(%p, %#x): stub\n", This, passes, flags);
2311 return E_NOTIMPL;
2314 static HRESULT WINAPI ID3DXEffectImpl_BeginPass(ID3DXEffect* iface, UINT pass)
2316 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2318 FIXME("(%p)->(%u): stub\n", This, pass);
2320 return E_NOTIMPL;
2323 static HRESULT WINAPI ID3DXEffectImpl_CommitChanges(ID3DXEffect* iface)
2325 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2327 FIXME("(%p)->(): stub\n", This);
2329 return E_NOTIMPL;
2332 static HRESULT WINAPI ID3DXEffectImpl_EndPass(ID3DXEffect* iface)
2334 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2336 FIXME("(%p)->(): stub\n", This);
2338 return E_NOTIMPL;
2341 static HRESULT WINAPI ID3DXEffectImpl_End(ID3DXEffect* iface)
2343 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2345 FIXME("(%p)->(): stub\n", This);
2347 return E_NOTIMPL;
2350 static HRESULT WINAPI ID3DXEffectImpl_GetDevice(ID3DXEffect *iface, LPDIRECT3DDEVICE9 *device)
2352 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2354 TRACE("iface %p, device %p\n", This, device);
2356 if (!device)
2358 WARN("Invalid argument supplied.\n");
2359 return D3DERR_INVALIDCALL;
2362 IDirect3DDevice9_AddRef(This->device);
2364 *device = This->device;
2366 TRACE("Returning device %p\n", *device);
2368 return S_OK;
2371 static HRESULT WINAPI ID3DXEffectImpl_OnLostDevice(ID3DXEffect* iface)
2373 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2375 FIXME("(%p)->(): stub\n", This);
2377 return E_NOTIMPL;
2380 static HRESULT WINAPI ID3DXEffectImpl_OnResetDevice(ID3DXEffect* iface)
2382 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2384 FIXME("(%p)->(): stub\n", This);
2386 return E_NOTIMPL;
2389 static HRESULT WINAPI ID3DXEffectImpl_SetStateManager(ID3DXEffect* iface, LPD3DXEFFECTSTATEMANAGER manager)
2391 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2393 FIXME("(%p)->(%p): stub\n", This, manager);
2395 return E_NOTIMPL;
2398 static HRESULT WINAPI ID3DXEffectImpl_GetStateManager(ID3DXEffect* iface, LPD3DXEFFECTSTATEMANAGER* manager)
2400 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2402 FIXME("(%p)->(%p): stub\n", This, manager);
2404 return E_NOTIMPL;
2407 static HRESULT WINAPI ID3DXEffectImpl_BeginParameterBlock(ID3DXEffect* iface)
2409 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2411 FIXME("(%p)->(): stub\n", This);
2413 return E_NOTIMPL;
2416 static D3DXHANDLE WINAPI ID3DXEffectImpl_EndParameterBlock(ID3DXEffect* iface)
2418 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2420 FIXME("(%p)->(): stub\n", This);
2422 return NULL;
2425 static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
2427 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2429 FIXME("(%p)->(%p): stub\n", This, parameter_block);
2431 return E_NOTIMPL;
2434 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block)
2436 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2438 FIXME("(%p)->(%p): stub\n", This, parameter_block);
2440 return E_NOTIMPL;
2443 static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect* iface, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT* effect)
2445 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2447 FIXME("(%p)->(%p, %p): stub\n", This, device, effect);
2449 return E_NOTIMPL;
2452 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect* iface, D3DXHANDLE parameter, LPCVOID data, UINT byte_offset, UINT bytes)
2454 struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface);
2456 FIXME("(%p)->(%p, %p, %u, %u): stub\n", This, parameter, data, byte_offset, bytes);
2458 return E_NOTIMPL;
2461 static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl =
2463 /*** IUnknown methods ***/
2464 ID3DXEffectImpl_QueryInterface,
2465 ID3DXEffectImpl_AddRef,
2466 ID3DXEffectImpl_Release,
2467 /*** ID3DXBaseEffect methods ***/
2468 ID3DXEffectImpl_GetDesc,
2469 ID3DXEffectImpl_GetParameterDesc,
2470 ID3DXEffectImpl_GetTechniqueDesc,
2471 ID3DXEffectImpl_GetPassDesc,
2472 ID3DXEffectImpl_GetFunctionDesc,
2473 ID3DXEffectImpl_GetParameter,
2474 ID3DXEffectImpl_GetParameterByName,
2475 ID3DXEffectImpl_GetParameterBySemantic,
2476 ID3DXEffectImpl_GetParameterElement,
2477 ID3DXEffectImpl_GetTechnique,
2478 ID3DXEffectImpl_GetTechniqueByName,
2479 ID3DXEffectImpl_GetPass,
2480 ID3DXEffectImpl_GetPassByName,
2481 ID3DXEffectImpl_GetFunction,
2482 ID3DXEffectImpl_GetFunctionByName,
2483 ID3DXEffectImpl_GetAnnotation,
2484 ID3DXEffectImpl_GetAnnotationByName,
2485 ID3DXEffectImpl_SetValue,
2486 ID3DXEffectImpl_GetValue,
2487 ID3DXEffectImpl_SetBool,
2488 ID3DXEffectImpl_GetBool,
2489 ID3DXEffectImpl_SetBoolArray,
2490 ID3DXEffectImpl_GetBoolArray,
2491 ID3DXEffectImpl_SetInt,
2492 ID3DXEffectImpl_GetInt,
2493 ID3DXEffectImpl_SetIntArray,
2494 ID3DXEffectImpl_GetIntArray,
2495 ID3DXEffectImpl_SetFloat,
2496 ID3DXEffectImpl_GetFloat,
2497 ID3DXEffectImpl_SetFloatArray,
2498 ID3DXEffectImpl_GetFloatArray,
2499 ID3DXEffectImpl_SetVector,
2500 ID3DXEffectImpl_GetVector,
2501 ID3DXEffectImpl_SetVectorArray,
2502 ID3DXEffectImpl_GetVectorArray,
2503 ID3DXEffectImpl_SetMatrix,
2504 ID3DXEffectImpl_GetMatrix,
2505 ID3DXEffectImpl_SetMatrixArray,
2506 ID3DXEffectImpl_GetMatrixArray,
2507 ID3DXEffectImpl_SetMatrixPointerArray,
2508 ID3DXEffectImpl_GetMatrixPointerArray,
2509 ID3DXEffectImpl_SetMatrixTranspose,
2510 ID3DXEffectImpl_GetMatrixTranspose,
2511 ID3DXEffectImpl_SetMatrixTransposeArray,
2512 ID3DXEffectImpl_GetMatrixTransposeArray,
2513 ID3DXEffectImpl_SetMatrixTransposePointerArray,
2514 ID3DXEffectImpl_GetMatrixTransposePointerArray,
2515 ID3DXEffectImpl_SetString,
2516 ID3DXEffectImpl_GetString,
2517 ID3DXEffectImpl_SetTexture,
2518 ID3DXEffectImpl_GetTexture,
2519 ID3DXEffectImpl_GetPixelShader,
2520 ID3DXEffectImpl_GetVertexShader,
2521 ID3DXEffectImpl_SetArrayRange,
2522 /*** ID3DXEffect methods ***/
2523 ID3DXEffectImpl_GetPool,
2524 ID3DXEffectImpl_SetTechnique,
2525 ID3DXEffectImpl_GetCurrentTechnique,
2526 ID3DXEffectImpl_ValidateTechnique,
2527 ID3DXEffectImpl_FindNextValidTechnique,
2528 ID3DXEffectImpl_IsParameterUsed,
2529 ID3DXEffectImpl_Begin,
2530 ID3DXEffectImpl_BeginPass,
2531 ID3DXEffectImpl_CommitChanges,
2532 ID3DXEffectImpl_EndPass,
2533 ID3DXEffectImpl_End,
2534 ID3DXEffectImpl_GetDevice,
2535 ID3DXEffectImpl_OnLostDevice,
2536 ID3DXEffectImpl_OnResetDevice,
2537 ID3DXEffectImpl_SetStateManager,
2538 ID3DXEffectImpl_GetStateManager,
2539 ID3DXEffectImpl_BeginParameterBlock,
2540 ID3DXEffectImpl_EndParameterBlock,
2541 ID3DXEffectImpl_ApplyParameterBlock,
2542 ID3DXEffectImpl_DeleteParameterBlock,
2543 ID3DXEffectImpl_CloneEffect,
2544 ID3DXEffectImpl_SetRawValue
2547 static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface)
2549 return CONTAINING_RECORD(iface, struct ID3DXEffectCompilerImpl, ID3DXEffectCompiler_iface);
2552 /*** IUnknown methods ***/
2553 static HRESULT WINAPI ID3DXEffectCompilerImpl_QueryInterface(ID3DXEffectCompiler *iface, REFIID riid, void **object)
2555 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2557 TRACE("iface %p, riid %s, object %p\n", This, debugstr_guid(riid), object);
2559 if (IsEqualGUID(riid, &IID_IUnknown) ||
2560 IsEqualGUID(riid, &IID_ID3DXEffectCompiler))
2562 This->ID3DXEffectCompiler_iface.lpVtbl->AddRef(iface);
2563 *object = This;
2564 return S_OK;
2567 ERR("Interface %s not found\n", debugstr_guid(riid));
2569 return E_NOINTERFACE;
2572 static ULONG WINAPI ID3DXEffectCompilerImpl_AddRef(ID3DXEffectCompiler *iface)
2574 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2576 TRACE("iface %p: AddRef from %u\n", iface, This->ref);
2578 return InterlockedIncrement(&This->ref);
2581 static ULONG WINAPI ID3DXEffectCompilerImpl_Release(ID3DXEffectCompiler *iface)
2583 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2584 ULONG ref = InterlockedDecrement(&This->ref);
2586 TRACE("iface %p: Release from %u\n", iface, ref + 1);
2588 if (!ref)
2590 free_effect_compiler(This);
2591 HeapFree(GetProcessHeap(), 0, This);
2594 return ref;
2597 /*** ID3DXBaseEffect methods ***/
2598 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetDesc(ID3DXEffectCompiler *iface, D3DXEFFECT_DESC *desc)
2600 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2601 ID3DXBaseEffect *base = This->base_effect;
2603 TRACE("Forward iface %p, base %p\n", This, base);
2605 return ID3DXBaseEffectImpl_GetDesc(base, desc);
2608 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetParameterDesc(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc)
2610 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2611 ID3DXBaseEffect *base = This->base_effect;
2613 TRACE("Forward iface %p, base %p\n", This, base);
2615 return ID3DXBaseEffectImpl_GetParameterDesc(base, parameter, desc);
2618 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTechniqueDesc(ID3DXEffectCompiler *iface, D3DXHANDLE technique, D3DXTECHNIQUE_DESC *desc)
2620 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2621 ID3DXBaseEffect *base = This->base_effect;
2623 TRACE("Forward iface %p, base %p\n", This, base);
2625 return ID3DXBaseEffectImpl_GetTechniqueDesc(base, technique, desc);
2628 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPassDesc(ID3DXEffectCompiler *iface, D3DXHANDLE pass, D3DXPASS_DESC *desc)
2630 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2631 ID3DXBaseEffect *base = This->base_effect;
2633 TRACE("Forward iface %p, base %p\n", This, base);
2635 return ID3DXBaseEffectImpl_GetPassDesc(base, pass, desc);
2638 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFunctionDesc(ID3DXEffectCompiler *iface, D3DXHANDLE shader, D3DXFUNCTION_DESC *desc)
2640 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2641 ID3DXBaseEffect *base = This->base_effect;
2643 TRACE("Forward iface %p, base %p\n", This, base);
2645 return ID3DXBaseEffectImpl_GetFunctionDesc(base, shader, desc);
2648 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameter(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
2650 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2651 ID3DXBaseEffect *base = This->base_effect;
2653 TRACE("Forward iface %p, base %p\n", This, base);
2655 return ID3DXBaseEffectImpl_GetParameter(base, parameter, index);
2658 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterByName(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR name)
2660 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2661 ID3DXBaseEffect *base = This->base_effect;
2663 TRACE("Forward iface %p, base %p\n", This, base);
2665 return ID3DXBaseEffectImpl_GetParameterByName(base, parameter, name);
2668 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterBySemantic(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR semantic)
2670 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2671 ID3DXBaseEffect *base = This->base_effect;
2673 TRACE("Forward iface %p, base %p\n", This, base);
2675 return ID3DXBaseEffectImpl_GetParameterBySemantic(base, parameter, semantic);
2678 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetParameterElement(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT index)
2680 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2681 ID3DXBaseEffect *base = This->base_effect;
2683 TRACE("Forward iface %p, base %p\n", This, base);
2685 return ID3DXBaseEffectImpl_GetParameterElement(base, parameter, index);
2688 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechnique(ID3DXEffectCompiler *iface, UINT index)
2690 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2691 ID3DXBaseEffect *base = This->base_effect;
2693 TRACE("Forward iface %p, base %p\n", This, base);
2695 return ID3DXBaseEffectImpl_GetTechnique(base, index);
2698 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetTechniqueByName(ID3DXEffectCompiler *iface, LPCSTR name)
2700 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2701 ID3DXBaseEffect *base = This->base_effect;
2703 TRACE("Forward iface %p, base %p\n", This, base);
2705 return ID3DXBaseEffectImpl_GetTechniqueByName(base, name);
2708 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPass(ID3DXEffectCompiler *iface, D3DXHANDLE technique, UINT index)
2710 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2711 ID3DXBaseEffect *base = This->base_effect;
2713 TRACE("Forward iface %p, base %p\n", This, base);
2715 return ID3DXBaseEffectImpl_GetPass(base, technique, index);
2718 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetPassByName(ID3DXEffectCompiler *iface, D3DXHANDLE technique, LPCSTR name)
2720 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2721 ID3DXBaseEffect *base = This->base_effect;
2723 TRACE("Forward iface %p, base %p\n", This, base);
2725 return ID3DXBaseEffectImpl_GetPassByName(base, technique, name);
2728 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunction(ID3DXEffectCompiler *iface, UINT index)
2730 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2731 ID3DXBaseEffect *base = This->base_effect;
2733 TRACE("Forward iface %p, base %p\n", This, base);
2735 return ID3DXBaseEffectImpl_GetFunction(base, index);
2738 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetFunctionByName(ID3DXEffectCompiler *iface, LPCSTR name)
2740 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2741 ID3DXBaseEffect *base = This->base_effect;
2743 TRACE("Forward iface %p, base %p\n", This, base);
2745 return ID3DXBaseEffectImpl_GetFunctionByName(base, name);
2748 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotation(ID3DXEffectCompiler *iface, D3DXHANDLE object, UINT index)
2750 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2751 ID3DXBaseEffect *base = This->base_effect;
2753 TRACE("Forward iface %p, base %p\n", This, base);
2755 return ID3DXBaseEffectImpl_GetAnnotation(base, object, index);
2758 static D3DXHANDLE WINAPI ID3DXEffectCompilerImpl_GetAnnotationByName(ID3DXEffectCompiler *iface, D3DXHANDLE object, LPCSTR name)
2760 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2761 ID3DXBaseEffect *base = This->base_effect;
2763 TRACE("Forward iface %p, base %p\n", This, base);
2765 return ID3DXBaseEffectImpl_GetAnnotationByName(base, object, name);
2768 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCVOID data, UINT bytes)
2770 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2771 ID3DXBaseEffect *base = This->base_effect;
2773 TRACE("Forward iface %p, base %p\n", This, base);
2775 return ID3DXBaseEffectImpl_SetValue(base, parameter, data, bytes);
2778 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetValue(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes)
2780 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2781 ID3DXBaseEffect *base = This->base_effect;
2783 TRACE("Forward iface %p, base %p\n", This, base);
2785 return ID3DXBaseEffectImpl_GetValue(base, parameter, data, bytes);
2788 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL b)
2790 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2791 ID3DXBaseEffect *base = This->base_effect;
2793 TRACE("Forward iface %p, base %p\n", This, base);
2795 return ID3DXBaseEffectImpl_SetBool(base, parameter, b);
2798 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBool(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b)
2800 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2801 ID3DXBaseEffect *base = This->base_effect;
2803 TRACE("Forward iface %p, base %p\n", This, base);
2805 return ID3DXBaseEffectImpl_GetBool(base, parameter, b);
2808 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST BOOL *b, UINT count)
2810 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2811 ID3DXBaseEffect *base = This->base_effect;
2813 TRACE("Forward iface %p, base %p\n", This, base);
2815 return ID3DXBaseEffectImpl_SetBoolArray(base, parameter, b, count);
2818 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetBoolArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *b, UINT count)
2820 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2821 ID3DXBaseEffect *base = This->base_effect;
2823 TRACE("Forward iface %p, base %p\n", This, base);
2825 return ID3DXBaseEffectImpl_GetBoolArray(base, parameter, b, count);
2828 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT n)
2830 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2831 ID3DXBaseEffect *base = This->base_effect;
2833 TRACE("Forward iface %p, base %p\n", This, base);
2835 return ID3DXBaseEffectImpl_SetInt(base, parameter, n);
2838 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetInt(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n)
2840 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2841 ID3DXBaseEffect *base = This->base_effect;
2843 TRACE("Forward iface %p, base %p\n", This, base);
2845 return ID3DXBaseEffectImpl_GetInt(base, parameter, n);
2848 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST INT *n, UINT count)
2850 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2851 ID3DXBaseEffect *base = This->base_effect;
2853 TRACE("Forward iface %p, base %p\n", This, base);
2855 return ID3DXBaseEffectImpl_SetIntArray(base, parameter, n, count);
2858 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetIntArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, INT *n, UINT count)
2860 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2861 ID3DXBaseEffect *base = This->base_effect;
2863 TRACE("Forward iface %p, base %p\n", This, base);
2865 return ID3DXBaseEffectImpl_GetIntArray(base, parameter, n, count);
2868 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT f)
2870 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2871 ID3DXBaseEffect *base = This->base_effect;
2873 TRACE("Forward iface %p, base %p\n", This, base);
2875 return ID3DXBaseEffectImpl_SetFloat(base, parameter, f);
2878 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloat(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f)
2880 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2881 ID3DXBaseEffect *base = This->base_effect;
2883 TRACE("Forward iface %p, base %p\n", This, base);
2885 return ID3DXBaseEffectImpl_GetFloat(base, parameter, f);
2888 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST FLOAT *f, UINT count)
2890 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2891 ID3DXBaseEffect *base = This->base_effect;
2893 TRACE("Forward iface %p, base %p\n", This, base);
2895 return ID3DXBaseEffectImpl_SetFloatArray(base, parameter, f, count);
2898 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetFloatArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, FLOAT *f, UINT count)
2900 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2901 ID3DXBaseEffect *base = This->base_effect;
2903 TRACE("Forward iface %p, base %p\n", This, base);
2905 return ID3DXBaseEffectImpl_GetFloatArray(base, parameter, f, count);
2908 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector)
2910 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2911 ID3DXBaseEffect *base = This->base_effect;
2913 TRACE("Forward iface %p, base %p\n", This, base);
2915 return ID3DXBaseEffectImpl_SetVector(base, parameter, vector);
2918 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVector(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector)
2920 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2921 ID3DXBaseEffect *base = This->base_effect;
2923 TRACE("Forward iface %p, base %p\n", This, base);
2925 return ID3DXBaseEffectImpl_GetVector(base, parameter, vector);
2928 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXVECTOR4 *vector, UINT count)
2930 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2931 ID3DXBaseEffect *base = This->base_effect;
2933 TRACE("Forward iface %p, base %p\n", This, base);
2935 return ID3DXBaseEffectImpl_SetVectorArray(base, parameter, vector, count);
2938 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVectorArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXVECTOR4 *vector, UINT count)
2940 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2941 ID3DXBaseEffect *base = This->base_effect;
2943 TRACE("Forward iface %p, base %p\n", This, base);
2945 return ID3DXBaseEffectImpl_GetVectorArray(base, parameter, vector, count);
2948 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
2950 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2951 ID3DXBaseEffect *base = This->base_effect;
2953 TRACE("Forward iface %p, base %p\n", This, base);
2955 return ID3DXBaseEffectImpl_SetMatrix(base, parameter, matrix);
2958 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrix(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
2960 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2961 ID3DXBaseEffect *base = This->base_effect;
2963 TRACE("Forward iface %p, base %p\n", This, base);
2965 return ID3DXBaseEffectImpl_GetMatrix(base, parameter, matrix);
2968 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
2970 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2971 ID3DXBaseEffect *base = This->base_effect;
2973 TRACE("Forward iface %p, base %p\n", This, base);
2975 return ID3DXBaseEffectImpl_SetMatrixArray(base, parameter, matrix, count);
2978 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
2980 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2981 ID3DXBaseEffect *base = This->base_effect;
2983 TRACE("Forward iface %p, base %p\n", This, base);
2985 return ID3DXBaseEffectImpl_GetMatrixArray(base, parameter, matrix, count);
2988 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
2990 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
2991 ID3DXBaseEffect *base = This->base_effect;
2993 TRACE("Forward iface %p, base %p\n", This, base);
2995 return ID3DXBaseEffectImpl_SetMatrixPointerArray(base, parameter, matrix, count);
2998 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixPointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3000 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3001 ID3DXBaseEffect *base = This->base_effect;
3003 TRACE("Forward iface %p, base %p\n", This, base);
3005 return ID3DXBaseEffectImpl_GetMatrixPointerArray(base, parameter, matrix, count);
3008 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix)
3010 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3011 ID3DXBaseEffect *base = This->base_effect;
3013 TRACE("Forward iface %p, base %p\n", This, base);
3015 return ID3DXBaseEffectImpl_SetMatrixTranspose(base, parameter, matrix);
3018 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTranspose(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix)
3020 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3021 ID3DXBaseEffect *base = This->base_effect;
3023 TRACE("Forward iface %p, base %p\n", This, base);
3025 return ID3DXBaseEffectImpl_GetMatrixTranspose(base, parameter, matrix);
3028 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX *matrix, UINT count)
3030 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3031 ID3DXBaseEffect *base = This->base_effect;
3033 TRACE("Forward iface %p, base %p\n", This, base);
3035 return ID3DXBaseEffectImpl_SetMatrixTransposeArray(base, parameter, matrix, count);
3038 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposeArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX *matrix, UINT count)
3040 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3041 ID3DXBaseEffect *base = This->base_effect;
3043 TRACE("Forward iface %p, base %p\n", This, base);
3045 return ID3DXBaseEffectImpl_GetMatrixTransposeArray(base, parameter, matrix, count);
3048 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, CONST D3DXMATRIX **matrix, UINT count)
3050 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3051 ID3DXBaseEffect *base = This->base_effect;
3053 TRACE("Forward iface %p, base %p\n", This, base);
3055 return ID3DXBaseEffectImpl_SetMatrixTransposePointerArray(base, parameter, matrix, count);
3058 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, D3DXMATRIX **matrix, UINT count)
3060 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3061 ID3DXBaseEffect *base = This->base_effect;
3063 TRACE("Forward iface %p, base %p\n", This, base);
3065 return ID3DXBaseEffectImpl_GetMatrixTransposePointerArray(base, parameter, matrix, count);
3068 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR string)
3070 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3071 ID3DXBaseEffect *base = This->base_effect;
3073 TRACE("Forward iface %p, base %p\n", This, base);
3075 return ID3DXBaseEffectImpl_SetString(base, parameter, string);
3078 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetString(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPCSTR *string)
3080 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3081 ID3DXBaseEffect *base = This->base_effect;
3083 TRACE("Forward iface %p, base %p\n", This, base);
3085 return ID3DXBaseEffectImpl_GetString(base, parameter, string);
3088 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture)
3090 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3091 ID3DXBaseEffect *base = This->base_effect;
3093 TRACE("Forward iface %p, base %p\n", This, base);
3095 return ID3DXBaseEffectImpl_SetTexture(base, parameter, texture);
3098 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetTexture(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture)
3100 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3101 ID3DXBaseEffect *base = This->base_effect;
3103 TRACE("Forward iface %p, base %p\n", This, base);
3105 return ID3DXBaseEffectImpl_GetTexture(base, parameter, texture);
3108 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetPixelShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader)
3110 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3111 ID3DXBaseEffect *base = This->base_effect;
3113 TRACE("Forward iface %p, base %p\n", This, base);
3115 return ID3DXBaseEffectImpl_GetPixelShader(base, parameter, pshader);
3118 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetVertexShader(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader)
3120 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3121 ID3DXBaseEffect *base = This->base_effect;
3123 TRACE("Forward iface %p, base %p\n", This, base);
3125 return ID3DXBaseEffectImpl_GetVertexShader(base, parameter, vshader);
3128 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetArrayRange(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, UINT start, UINT end)
3130 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3131 ID3DXBaseEffect *base = This->base_effect;
3133 TRACE("Forward iface %p, base %p\n", This, base);
3135 return ID3DXBaseEffectImpl_SetArrayRange(base, parameter, start, end);
3138 /*** ID3DXEffectCompiler methods ***/
3139 static HRESULT WINAPI ID3DXEffectCompilerImpl_SetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL literal)
3141 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3143 FIXME("iface %p, parameter %p, literal %u\n", This, parameter, literal);
3145 return E_NOTIMPL;
3148 static HRESULT WINAPI ID3DXEffectCompilerImpl_GetLiteral(ID3DXEffectCompiler *iface, D3DXHANDLE parameter, BOOL *literal)
3150 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3152 FIXME("iface %p, parameter %p, literal %p\n", This, parameter, literal);
3154 return E_NOTIMPL;
3157 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileEffect(ID3DXEffectCompiler *iface, DWORD flags,
3158 LPD3DXBUFFER *effect, LPD3DXBUFFER *error_msgs)
3160 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3162 FIXME("iface %p, flags %#x, effect %p, error_msgs %p stub\n", This, flags, effect, error_msgs);
3164 return E_NOTIMPL;
3167 static HRESULT WINAPI ID3DXEffectCompilerImpl_CompileShader(ID3DXEffectCompiler *iface, D3DXHANDLE function,
3168 LPCSTR target, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *error_msgs, LPD3DXCONSTANTTABLE *constant_table)
3170 struct ID3DXEffectCompilerImpl *This = impl_from_ID3DXEffectCompiler(iface);
3172 FIXME("iface %p, function %p, target %p, flags %#x, shader %p, error_msgs %p, constant_table %p stub\n",
3173 This, function, target, flags, shader, error_msgs, constant_table);
3175 return E_NOTIMPL;
3178 static const struct ID3DXEffectCompilerVtbl ID3DXEffectCompiler_Vtbl =
3180 /*** IUnknown methods ***/
3181 ID3DXEffectCompilerImpl_QueryInterface,
3182 ID3DXEffectCompilerImpl_AddRef,
3183 ID3DXEffectCompilerImpl_Release,
3184 /*** ID3DXBaseEffect methods ***/
3185 ID3DXEffectCompilerImpl_GetDesc,
3186 ID3DXEffectCompilerImpl_GetParameterDesc,
3187 ID3DXEffectCompilerImpl_GetTechniqueDesc,
3188 ID3DXEffectCompilerImpl_GetPassDesc,
3189 ID3DXEffectCompilerImpl_GetFunctionDesc,
3190 ID3DXEffectCompilerImpl_GetParameter,
3191 ID3DXEffectCompilerImpl_GetParameterByName,
3192 ID3DXEffectCompilerImpl_GetParameterBySemantic,
3193 ID3DXEffectCompilerImpl_GetParameterElement,
3194 ID3DXEffectCompilerImpl_GetTechnique,
3195 ID3DXEffectCompilerImpl_GetTechniqueByName,
3196 ID3DXEffectCompilerImpl_GetPass,
3197 ID3DXEffectCompilerImpl_GetPassByName,
3198 ID3DXEffectCompilerImpl_GetFunction,
3199 ID3DXEffectCompilerImpl_GetFunctionByName,
3200 ID3DXEffectCompilerImpl_GetAnnotation,
3201 ID3DXEffectCompilerImpl_GetAnnotationByName,
3202 ID3DXEffectCompilerImpl_SetValue,
3203 ID3DXEffectCompilerImpl_GetValue,
3204 ID3DXEffectCompilerImpl_SetBool,
3205 ID3DXEffectCompilerImpl_GetBool,
3206 ID3DXEffectCompilerImpl_SetBoolArray,
3207 ID3DXEffectCompilerImpl_GetBoolArray,
3208 ID3DXEffectCompilerImpl_SetInt,
3209 ID3DXEffectCompilerImpl_GetInt,
3210 ID3DXEffectCompilerImpl_SetIntArray,
3211 ID3DXEffectCompilerImpl_GetIntArray,
3212 ID3DXEffectCompilerImpl_SetFloat,
3213 ID3DXEffectCompilerImpl_GetFloat,
3214 ID3DXEffectCompilerImpl_SetFloatArray,
3215 ID3DXEffectCompilerImpl_GetFloatArray,
3216 ID3DXEffectCompilerImpl_SetVector,
3217 ID3DXEffectCompilerImpl_GetVector,
3218 ID3DXEffectCompilerImpl_SetVectorArray,
3219 ID3DXEffectCompilerImpl_GetVectorArray,
3220 ID3DXEffectCompilerImpl_SetMatrix,
3221 ID3DXEffectCompilerImpl_GetMatrix,
3222 ID3DXEffectCompilerImpl_SetMatrixArray,
3223 ID3DXEffectCompilerImpl_GetMatrixArray,
3224 ID3DXEffectCompilerImpl_SetMatrixPointerArray,
3225 ID3DXEffectCompilerImpl_GetMatrixPointerArray,
3226 ID3DXEffectCompilerImpl_SetMatrixTranspose,
3227 ID3DXEffectCompilerImpl_GetMatrixTranspose,
3228 ID3DXEffectCompilerImpl_SetMatrixTransposeArray,
3229 ID3DXEffectCompilerImpl_GetMatrixTransposeArray,
3230 ID3DXEffectCompilerImpl_SetMatrixTransposePointerArray,
3231 ID3DXEffectCompilerImpl_GetMatrixTransposePointerArray,
3232 ID3DXEffectCompilerImpl_SetString,
3233 ID3DXEffectCompilerImpl_GetString,
3234 ID3DXEffectCompilerImpl_SetTexture,
3235 ID3DXEffectCompilerImpl_GetTexture,
3236 ID3DXEffectCompilerImpl_GetPixelShader,
3237 ID3DXEffectCompilerImpl_GetVertexShader,
3238 ID3DXEffectCompilerImpl_SetArrayRange,
3239 /*** ID3DXEffectCompiler methods ***/
3240 ID3DXEffectCompilerImpl_SetLiteral,
3241 ID3DXEffectCompilerImpl_GetLiteral,
3242 ID3DXEffectCompilerImpl_CompileEffect,
3243 ID3DXEffectCompilerImpl_CompileShader,
3246 static HRESULT d3dx9_parse_value(struct d3dx_parameter *param, void *value, const char **ptr)
3248 unsigned int i;
3249 HRESULT hr;
3250 UINT old_size = 0;
3251 DWORD id;
3253 if (param->element_count)
3255 param->data = value;
3257 for (i = 0; i < param->element_count; ++i)
3259 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3261 hr = d3dx9_parse_value(member, (char *)value + old_size, ptr);
3262 if (hr != D3D_OK)
3264 WARN("Failed to parse value\n");
3265 return hr;
3268 old_size += member->bytes;
3271 return D3D_OK;
3274 switch(param->class)
3276 case D3DXPC_SCALAR:
3277 case D3DXPC_VECTOR:
3278 case D3DXPC_MATRIX_ROWS:
3279 case D3DXPC_MATRIX_COLUMNS:
3280 param->data = value;
3281 break;
3283 case D3DXPC_STRUCT:
3284 param->data = value;
3286 for (i = 0; i < param->member_count; ++i)
3288 struct d3dx_parameter *member = get_parameter_struct(param->member_handles[i]);
3290 hr = d3dx9_parse_value(member, (char *)value + old_size, ptr);
3291 if (hr != D3D_OK)
3293 WARN("Failed to parse value\n");
3294 return hr;
3297 old_size += member->bytes;
3299 break;
3301 case D3DXPC_OBJECT:
3302 switch (param->type)
3304 case D3DXPT_STRING:
3305 case D3DXPT_PIXELSHADER:
3306 case D3DXPT_VERTEXSHADER:
3307 read_dword(ptr, &id);
3308 TRACE("Id: %u\n", id);
3309 param->base->objects[id] = get_parameter_handle(param);
3310 param->data = value;
3311 break;
3313 default:
3314 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3315 break;
3317 break;
3319 default:
3320 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
3321 break;
3324 return D3D_OK;
3327 static HRESULT d3dx9_parse_init_value(struct d3dx_parameter *param, const char *ptr)
3329 UINT size = param->bytes;
3330 HRESULT hr;
3331 void *value = NULL;
3333 TRACE("param size: %u\n", size);
3335 value = HeapAlloc(GetProcessHeap(), 0, size);
3336 if (!value)
3338 ERR("Failed to allocate data memory.\n");
3339 return E_OUTOFMEMORY;
3342 TRACE("Data: %s.\n", debugstr_an(ptr, size));
3343 memcpy(value, ptr, size);
3345 hr = d3dx9_parse_value(param, value, &ptr);
3346 if (hr != D3D_OK)
3348 WARN("Failed to parse value\n");
3349 HeapFree(GetProcessHeap(), 0, value);
3350 return hr;
3353 param->data = value;
3355 return D3D_OK;
3358 static HRESULT d3dx9_parse_name(char **name, const char *ptr)
3360 DWORD size;
3362 read_dword(&ptr, &size);
3363 TRACE("Name size: %#x\n", size);
3365 if (!size)
3367 return D3D_OK;
3370 *name = HeapAlloc(GetProcessHeap(), 0, size);
3371 if (!*name)
3373 ERR("Failed to allocate name memory.\n");
3374 return E_OUTOFMEMORY;
3377 TRACE("Name: %s.\n", debugstr_an(ptr, size));
3378 memcpy(*name, ptr, size);
3380 return D3D_OK;
3383 static HRESULT d3dx9_parse_data(struct d3dx_parameter *param, const char **ptr)
3385 DWORD size;
3386 HRESULT hr;
3388 TRACE("Parse data for parameter %s, type %s\n", debugstr_a(param->name), debug_d3dxparameter_type(param->type));
3390 read_dword(ptr, &size);
3391 TRACE("Data size: %#x\n", size);
3393 if (!size)
3395 TRACE("Size is 0\n");
3396 *(void **)param->data = NULL;
3397 return D3D_OK;
3400 switch (param->type)
3402 case D3DXPT_STRING:
3403 /* re-read with size (sizeof(DWORD) = 4) */
3404 hr = d3dx9_parse_name((LPSTR *)param->data, *ptr - 4);
3405 if (hr != D3D_OK)
3407 WARN("Failed to parse string data\n");
3408 return hr;
3410 break;
3412 case D3DXPT_VERTEXSHADER:
3413 hr = IDirect3DDevice9_CreateVertexShader(param->base->effect->device, (DWORD *)*ptr, (LPDIRECT3DVERTEXSHADER9 *)param->data);
3414 if (hr != D3D_OK)
3416 WARN("Failed to create vertex shader\n");
3417 return hr;
3419 break;
3421 case D3DXPT_PIXELSHADER:
3422 hr = IDirect3DDevice9_CreatePixelShader(param->base->effect->device, (DWORD *)*ptr, (LPDIRECT3DPIXELSHADER9 *)param->data);
3423 if (hr != D3D_OK)
3425 WARN("Failed to create pixel shader\n");
3426 return hr;
3428 break;
3430 default:
3431 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3432 break;
3436 *ptr += ((size + 3) & ~3);
3438 return D3D_OK;
3441 static HRESULT d3dx9_parse_effect_typedef(struct d3dx_parameter *param, const char *data, const char **ptr,
3442 struct d3dx_parameter *parent, UINT flags)
3444 DWORD offset;
3445 HRESULT hr;
3446 D3DXHANDLE *member_handles = NULL;
3447 UINT i;
3449 param->flags = flags;
3451 if (!parent)
3453 read_dword(ptr, &param->type);
3454 TRACE("Type: %s\n", debug_d3dxparameter_type(param->type));
3456 read_dword(ptr, &param->class);
3457 TRACE("Class: %s\n", debug_d3dxparameter_class(param->class));
3459 read_dword(ptr, &offset);
3460 TRACE("Type name offset: %#x\n", offset);
3461 hr = d3dx9_parse_name(&param->name, data + offset);
3462 if (hr != D3D_OK)
3464 WARN("Failed to parse name\n");
3465 goto err_out;
3468 read_dword(ptr, &offset);
3469 TRACE("Type semantic offset: %#x\n", offset);
3470 hr = d3dx9_parse_name(&param->semantic, data + offset);
3471 if (hr != D3D_OK)
3473 WARN("Failed to parse semantic\n");
3474 goto err_out;
3477 read_dword(ptr, &param->element_count);
3478 TRACE("Elements: %u\n", param->element_count);
3480 switch (param->class)
3482 case D3DXPC_VECTOR:
3483 read_dword(ptr, &param->columns);
3484 TRACE("Columns: %u\n", param->columns);
3486 read_dword(ptr, &param->rows);
3487 TRACE("Rows: %u\n", param->rows);
3489 /* sizeof(DWORD) * rows * columns */
3490 param->bytes = 4 * param->rows * param->columns;
3491 break;
3493 case D3DXPC_SCALAR:
3494 case D3DXPC_MATRIX_ROWS:
3495 case D3DXPC_MATRIX_COLUMNS:
3496 read_dword(ptr, &param->rows);
3497 TRACE("Rows: %u\n", param->rows);
3499 read_dword(ptr, &param->columns);
3500 TRACE("Columns: %u\n", param->columns);
3502 /* sizeof(DWORD) * rows * columns */
3503 param->bytes = 4 * param->rows * param->columns;
3504 break;
3506 case D3DXPC_STRUCT:
3507 read_dword(ptr, &param->member_count);
3508 TRACE("Members: %u\n", param->member_count);
3509 break;
3511 case D3DXPC_OBJECT:
3512 switch (param->type)
3514 case D3DXPT_STRING:
3515 param->bytes = sizeof(LPCSTR);
3516 break;
3518 case D3DXPT_PIXELSHADER:
3519 param->bytes = sizeof(LPDIRECT3DPIXELSHADER9);
3520 break;
3522 case D3DXPT_VERTEXSHADER:
3523 param->bytes = sizeof(LPDIRECT3DVERTEXSHADER9);
3524 break;
3526 default:
3527 FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
3528 break;
3530 break;
3532 default:
3533 FIXME("Unhandled class %s\n", debug_d3dxparameter_class(param->class));
3534 break;
3537 else
3539 /* elements */
3540 param->type = parent->type;
3541 param->class = parent->class;
3542 param->name = parent->name;
3543 param->semantic = parent->semantic;
3544 param->element_count = 0;
3545 param->annotation_count = 0;
3546 param->member_count = parent->member_count;
3547 param->bytes = parent->bytes;
3548 param->rows = parent->rows;
3549 param->columns = parent->columns;
3552 if (param->element_count)
3554 unsigned int param_bytes = 0;
3555 const char *save_ptr = *ptr;
3557 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->element_count);
3558 if (!member_handles)
3560 ERR("Out of memory\n");
3561 hr = E_OUTOFMEMORY;
3562 goto err_out;
3565 for (i = 0; i < param->element_count; ++i)
3567 struct d3dx_parameter *member;
3568 *ptr = save_ptr;
3570 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
3571 if (!member)
3573 ERR("Out of memory\n");
3574 hr = E_OUTOFMEMORY;
3575 goto err_out;
3578 member_handles[i] = get_parameter_handle(member);
3579 member->base = param->base;
3581 hr = d3dx9_parse_effect_typedef(member, data, ptr, param, flags);
3582 if (hr != D3D_OK)
3584 WARN("Failed to parse member\n");
3585 goto err_out;
3588 param_bytes += member->bytes;
3591 param->bytes = param_bytes;
3593 else if (param->member_count)
3595 member_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member_handles) * param->member_count);
3596 if (!member_handles)
3598 ERR("Out of memory\n");
3599 hr = E_OUTOFMEMORY;
3600 goto err_out;
3603 for (i = 0; i < param->member_count; ++i)
3605 struct d3dx_parameter *member;
3607 member = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*member));
3608 if (!member)
3610 ERR("Out of memory\n");
3611 hr = E_OUTOFMEMORY;
3612 goto err_out;
3615 member_handles[i] = get_parameter_handle(member);
3616 member->base = param->base;
3618 hr = d3dx9_parse_effect_typedef(member, data, ptr, NULL, flags);
3619 if (hr != D3D_OK)
3621 WARN("Failed to parse member\n");
3622 goto err_out;
3625 param->bytes += member->bytes;
3629 param->member_handles = member_handles;
3631 return D3D_OK;
3633 err_out:
3635 if (member_handles)
3637 unsigned int count;
3639 if (param->element_count) count = param->element_count;
3640 else count = param->member_count;
3642 for (i = 0; i < count; ++i)
3644 free_parameter(member_handles[i], param->element_count != 0, TRUE);
3646 HeapFree(GetProcessHeap(), 0, member_handles);
3649 if (!parent)
3651 HeapFree(GetProcessHeap(), 0, param->name);
3652 HeapFree(GetProcessHeap(), 0, param->semantic);
3654 param->name = NULL;
3655 param->semantic = NULL;
3657 return hr;
3660 static HRESULT d3dx9_parse_effect_annotation(struct d3dx_parameter *anno, const char *data, const char **ptr)
3662 DWORD offset;
3663 const char *ptr2;
3664 HRESULT hr;
3666 anno->flags = D3DX_PARAMETER_ANNOTATION;
3668 read_dword(ptr, &offset);
3669 TRACE("Typedef offset: %#x\n", offset);
3670 ptr2 = data + offset;
3671 hr = d3dx9_parse_effect_typedef(anno, data, &ptr2, NULL, D3DX_PARAMETER_ANNOTATION);
3672 if (hr != D3D_OK)
3674 WARN("Failed to parse type definition\n");
3675 return hr;
3678 read_dword(ptr, &offset);
3679 TRACE("Value offset: %#x\n", offset);
3680 hr = d3dx9_parse_init_value(anno, data + offset);
3681 if (hr != D3D_OK)
3683 WARN("Failed to parse value\n");
3684 return hr;
3687 return D3D_OK;
3690 static HRESULT d3dx9_parse_effect_parameter(struct d3dx_parameter *param, const char *data, const char **ptr)
3692 DWORD offset;
3693 HRESULT hr;
3694 unsigned int i;
3695 D3DXHANDLE *annotation_handles = NULL;
3696 const char *ptr2;
3698 read_dword(ptr, &offset);
3699 TRACE("Typedef offset: %#x\n", offset);
3700 ptr2 = data + offset;
3702 read_dword(ptr, &offset);
3703 TRACE("Value offset: %#x\n", offset);
3705 read_dword(ptr, &param->flags);
3706 TRACE("Flags: %#x\n", param->flags);
3708 read_dword(ptr, &param->annotation_count);
3709 TRACE("Annotation count: %u\n", param->annotation_count);
3711 hr = d3dx9_parse_effect_typedef(param, data, &ptr2, NULL, param->flags);
3712 if (hr != D3D_OK)
3714 WARN("Failed to parse type definition\n");
3715 return hr;
3718 hr = d3dx9_parse_init_value(param, data + offset);
3719 if (hr != D3D_OK)
3721 WARN("Failed to parse value\n");
3722 return hr;
3725 if (param->annotation_count)
3727 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * param->annotation_count);
3728 if (!annotation_handles)
3730 ERR("Out of memory\n");
3731 hr = E_OUTOFMEMORY;
3732 goto err_out;
3735 for (i = 0; i < param->annotation_count; ++i)
3737 struct d3dx_parameter *annotation;
3739 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
3740 if (!annotation)
3742 ERR("Out of memory\n");
3743 hr = E_OUTOFMEMORY;
3744 goto err_out;
3747 annotation_handles[i] = get_parameter_handle(annotation);
3748 annotation->base = param->base;
3750 hr = d3dx9_parse_effect_annotation(annotation, data, ptr);
3751 if (hr != D3D_OK)
3753 WARN("Failed to parse annotation\n");
3754 goto err_out;
3759 param->annotation_handles = annotation_handles;
3761 return D3D_OK;
3763 err_out:
3765 if (annotation_handles)
3767 for (i = 0; i < param->annotation_count; ++i)
3769 free_parameter(annotation_handles[i], FALSE, FALSE);
3771 HeapFree(GetProcessHeap(), 0, annotation_handles);
3774 return hr;
3777 static HRESULT d3dx9_parse_effect_pass(struct d3dx_pass *pass, const char *data, const char **ptr)
3779 DWORD offset;
3780 HRESULT hr;
3781 unsigned int i;
3782 D3DXHANDLE *annotation_handles = NULL;
3783 char *name = NULL;
3785 read_dword(ptr, &offset);
3786 TRACE("Pass name offset: %#x\n", offset);
3787 hr = d3dx9_parse_name(&name, data + offset);
3788 if (hr != D3D_OK)
3790 WARN("Failed to parse name\n");
3791 goto err_out;
3794 read_dword(ptr, &pass->annotation_count);
3795 TRACE("Annotation count: %u\n", pass->annotation_count);
3797 read_dword(ptr, &pass->state_count);
3798 TRACE("State count: %u\n", pass->state_count);
3800 if (pass->annotation_count)
3802 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * pass->annotation_count);
3803 if (!annotation_handles)
3805 ERR("Out of memory\n");
3806 hr = E_OUTOFMEMORY;
3807 goto err_out;
3810 for (i = 0; i < pass->annotation_count; ++i)
3812 struct d3dx_parameter *annotation;
3814 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
3815 if (!annotation)
3817 ERR("Out of memory\n");
3818 hr = E_OUTOFMEMORY;
3819 goto err_out;
3822 annotation_handles[i] = get_parameter_handle(annotation);
3823 annotation->base = pass->base;
3825 hr = d3dx9_parse_effect_annotation(annotation, data, ptr);
3826 if (hr != D3D_OK)
3828 WARN("Failed to parse annotations\n");
3829 goto err_out;
3834 if (pass->state_count)
3836 for (i = 0; i < pass->state_count; ++i)
3838 skip_dword_unknown(ptr, 4);
3842 pass->name = name;
3843 pass->annotation_handles = annotation_handles;
3845 return D3D_OK;
3847 err_out:
3849 if (annotation_handles)
3851 for (i = 0; i < pass->annotation_count; ++i)
3853 free_parameter(annotation_handles[i], FALSE, FALSE);
3855 HeapFree(GetProcessHeap(), 0, annotation_handles);
3858 HeapFree(GetProcessHeap(), 0, name);
3860 return hr;
3863 static HRESULT d3dx9_parse_effect_technique(struct d3dx_technique *technique, const char *data, const char **ptr)
3865 DWORD offset;
3866 HRESULT hr;
3867 unsigned int i;
3868 D3DXHANDLE *annotation_handles = NULL;
3869 D3DXHANDLE *pass_handles = NULL;
3870 char *name = NULL;
3872 read_dword(ptr, &offset);
3873 TRACE("Technique name offset: %#x\n", offset);
3874 hr = d3dx9_parse_name(&name, data + offset);
3875 if (hr != D3D_OK)
3877 WARN("Failed to parse name\n");
3878 goto err_out;
3881 read_dword(ptr, &technique->annotation_count);
3882 TRACE("Annotation count: %u\n", technique->annotation_count);
3884 read_dword(ptr, &technique->pass_count);
3885 TRACE("Pass count: %u\n", technique->pass_count);
3887 if (technique->annotation_count)
3889 annotation_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation_handles) * technique->annotation_count);
3890 if (!annotation_handles)
3892 ERR("Out of memory\n");
3893 hr = E_OUTOFMEMORY;
3894 goto err_out;
3897 for (i = 0; i < technique->annotation_count; ++i)
3899 struct d3dx_parameter *annotation;
3901 annotation = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*annotation));
3902 if (!annotation)
3904 ERR("Out of memory\n");
3905 hr = E_OUTOFMEMORY;
3906 goto err_out;
3909 annotation_handles[i] = get_parameter_handle(annotation);
3910 annotation->base = technique->base;
3912 hr = d3dx9_parse_effect_annotation(annotation, data, ptr);
3913 if (hr != D3D_OK)
3915 WARN("Failed to parse annotations\n");
3916 goto err_out;
3921 if (technique->pass_count)
3923 pass_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass_handles) * technique->pass_count);
3924 if (!pass_handles)
3926 ERR("Out of memory\n");
3927 hr = E_OUTOFMEMORY;
3928 goto err_out;
3931 for (i = 0; i < technique->pass_count; ++i)
3933 struct d3dx_pass *pass;
3935 pass = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pass));
3936 if (!pass)
3938 ERR("Out of memory\n");
3939 hr = E_OUTOFMEMORY;
3940 goto err_out;
3943 pass_handles[i] = get_pass_handle(pass);
3944 pass->base = technique->base;
3946 hr = d3dx9_parse_effect_pass(pass, data, ptr);
3947 if (hr != D3D_OK)
3949 WARN("Failed to parse passes\n");
3950 goto err_out;
3955 technique->name = name;
3956 technique->pass_handles = pass_handles;
3957 technique->annotation_handles = annotation_handles;
3959 return D3D_OK;
3961 err_out:
3963 if (pass_handles)
3965 for (i = 0; i < technique->pass_count; ++i)
3967 free_pass(pass_handles[i]);
3969 HeapFree(GetProcessHeap(), 0, pass_handles);
3972 if (annotation_handles)
3974 for (i = 0; i < technique->annotation_count; ++i)
3976 free_parameter(annotation_handles[i], FALSE, FALSE);
3978 HeapFree(GetProcessHeap(), 0, annotation_handles);
3981 HeapFree(GetProcessHeap(), 0, name);
3983 return hr;
3986 static HRESULT d3dx9_parse_effect(struct ID3DXBaseEffectImpl *base, const char *data, UINT data_size, DWORD start)
3988 const char *ptr = data + start;
3989 D3DXHANDLE *parameter_handles = NULL;
3990 D3DXHANDLE *technique_handles = NULL;
3991 D3DXHANDLE *objects = NULL;
3992 unsigned int stringcount;
3993 HRESULT hr;
3994 unsigned int i;
3996 read_dword(&ptr, &base->parameter_count);
3997 TRACE("Parameter count: %u\n", base->parameter_count);
3999 read_dword(&ptr, &base->technique_count);
4000 TRACE("Technique count: %u\n", base->technique_count);
4002 skip_dword_unknown(&ptr, 1);
4004 read_dword(&ptr, &base->object_count);
4005 TRACE("Object count: %u\n", base->object_count);
4007 objects = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*objects) * base->object_count);
4008 if (!objects)
4010 ERR("Out of memory\n");
4011 hr = E_OUTOFMEMORY;
4012 goto err_out;
4015 base->objects = objects;
4017 if (base->parameter_count)
4019 parameter_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter_handles) * base->parameter_count);
4020 if (!parameter_handles)
4022 ERR("Out of memory\n");
4023 hr = E_OUTOFMEMORY;
4024 goto err_out;
4027 for (i = 0; i < base->parameter_count; ++i)
4029 struct d3dx_parameter *parameter;
4031 parameter = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*parameter));
4032 if (!parameter)
4034 ERR("Out of memory\n");
4035 hr = E_OUTOFMEMORY;
4036 goto err_out;
4039 parameter_handles[i] = get_parameter_handle(parameter);
4040 parameter->base = base;
4042 hr = d3dx9_parse_effect_parameter(parameter, data, &ptr);
4043 if (hr != D3D_OK)
4045 WARN("Failed to parse parameter\n");
4046 goto err_out;
4051 if (base->technique_count)
4053 technique_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique_handles) * base->technique_count);
4054 if (!technique_handles)
4056 ERR("Out of memory\n");
4057 hr = E_OUTOFMEMORY;
4058 goto err_out;
4061 for (i = 0; i < base->technique_count; ++i)
4063 struct d3dx_technique *technique;
4065 technique = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*technique));
4066 if (!technique)
4068 ERR("Out of memory\n");
4069 hr = E_OUTOFMEMORY;
4070 goto err_out;
4073 technique_handles[i] = get_technique_handle(technique);
4074 technique->base = base;
4076 hr = d3dx9_parse_effect_technique(technique, data, &ptr);
4077 if (hr != D3D_OK)
4079 WARN("Failed to parse technique\n");
4080 goto err_out;
4085 read_dword(&ptr, &stringcount);
4086 TRACE("String count: %u\n", stringcount);
4088 skip_dword_unknown(&ptr, 1);
4090 for (i = 0; i < stringcount; ++i)
4092 DWORD id;
4093 struct d3dx_parameter *param;
4095 read_dword(&ptr, &id);
4096 TRACE("Id: %u\n", id);
4098 param = get_parameter_struct(base->objects[id]);
4100 hr = d3dx9_parse_data(param, &ptr);
4101 if (hr != D3D_OK)
4103 WARN("Failed to parse data\n");
4104 goto err_out;
4108 HeapFree(GetProcessHeap(), 0, objects);
4109 base->objects = NULL;
4111 base->technique_handles = technique_handles;
4112 base->parameter_handles = parameter_handles;
4114 return D3D_OK;
4116 err_out:
4118 if (technique_handles)
4120 for (i = 0; i < base->technique_count; ++i)
4122 free_technique(technique_handles[i]);
4124 HeapFree(GetProcessHeap(), 0, technique_handles);
4127 if (parameter_handles)
4129 for (i = 0; i < base->parameter_count; ++i)
4131 free_parameter(parameter_handles[i], FALSE, FALSE);
4133 HeapFree(GetProcessHeap(), 0, parameter_handles);
4136 HeapFree(GetProcessHeap(), 0, objects);
4138 return hr;
4141 static HRESULT d3dx9_base_effect_init(struct ID3DXBaseEffectImpl *base,
4142 const char *data, SIZE_T data_size, struct ID3DXEffectImpl *effect)
4144 DWORD tag, offset;
4145 const char *ptr = data;
4146 HRESULT hr;
4148 TRACE("base %p, data %p, data_size %lu, effect %p\n", base, data, data_size, effect);
4150 base->ID3DXBaseEffect_iface.lpVtbl = &ID3DXBaseEffect_Vtbl;
4151 base->ref = 1;
4152 base->effect = effect;
4154 read_dword(&ptr, &tag);
4155 TRACE("Tag: %x\n", tag);
4157 if (tag != d3dx9_effect_version(9, 1))
4159 /* todo: compile hlsl ascii code */
4160 FIXME("HLSL ascii effects not supported, yet\n");
4162 /* Show the start of the shader for debugging info. */
4163 TRACE("effect:\n%s\n", debugstr_an(data, data_size > 40 ? 40 : data_size));
4165 else
4167 read_dword(&ptr, &offset);
4168 TRACE("Offset: %x\n", offset);
4170 hr = d3dx9_parse_effect(base, ptr, data_size, offset);
4171 if (hr != D3D_OK)
4173 FIXME("Failed to parse effect.\n");
4174 return hr;
4178 return D3D_OK;
4181 static HRESULT d3dx9_effect_init(struct ID3DXEffectImpl *effect, LPDIRECT3DDEVICE9 device,
4182 const char *data, SIZE_T data_size, LPD3DXEFFECTPOOL pool)
4184 HRESULT hr;
4185 struct ID3DXBaseEffectImpl *object = NULL;
4187 TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool);
4189 effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl;
4190 effect->ref = 1;
4192 if (pool) pool->lpVtbl->AddRef(pool);
4193 effect->pool = pool;
4195 IDirect3DDevice9_AddRef(device);
4196 effect->device = device;
4198 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4199 if (!object)
4201 ERR("Out of memory\n");
4202 hr = E_OUTOFMEMORY;
4203 goto err_out;
4206 hr = d3dx9_base_effect_init(object, data, data_size, effect);
4207 if (hr != D3D_OK)
4209 FIXME("Failed to parse effect.\n");
4210 goto err_out;
4213 effect->base_effect = &object->ID3DXBaseEffect_iface;
4215 return D3D_OK;
4217 err_out:
4219 HeapFree(GetProcessHeap(), 0, object);
4220 free_effect(effect);
4222 return hr;
4225 HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 device,
4226 LPCVOID srcdata,
4227 UINT srcdatalen,
4228 CONST D3DXMACRO* defines,
4229 LPD3DXINCLUDE include,
4230 LPCSTR skip_constants,
4231 DWORD flags,
4232 LPD3DXEFFECTPOOL pool,
4233 LPD3DXEFFECT* effect,
4234 LPD3DXBUFFER* compilation_errors)
4236 struct ID3DXEffectImpl *object;
4237 HRESULT hr;
4239 FIXME("(%p, %p, %u, %p, %p, %p, %#x, %p, %p, %p): semi-stub\n", device, srcdata, srcdatalen, defines, include,
4240 skip_constants, flags, pool, effect, compilation_errors);
4242 if (!device || !srcdata)
4243 return D3DERR_INVALIDCALL;
4245 if (!srcdatalen)
4246 return E_FAIL;
4248 /* Native dll allows effect to be null so just return D3D_OK after doing basic checks */
4249 if (!effect)
4250 return D3D_OK;
4252 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4253 if (!object)
4255 ERR("Out of memory\n");
4256 return E_OUTOFMEMORY;
4259 hr = d3dx9_effect_init(object, device, srcdata, srcdatalen, pool);
4260 if (FAILED(hr))
4262 WARN("Failed to initialize shader reflection\n");
4263 HeapFree(GetProcessHeap(), 0, object);
4264 return hr;
4267 *effect = &object->ID3DXEffect_iface;
4269 TRACE("Created ID3DXEffect %p\n", object);
4271 return D3D_OK;
4274 HRESULT WINAPI D3DXCreateEffect(LPDIRECT3DDEVICE9 device,
4275 LPCVOID srcdata,
4276 UINT srcdatalen,
4277 CONST D3DXMACRO* defines,
4278 LPD3DXINCLUDE include,
4279 DWORD flags,
4280 LPD3DXEFFECTPOOL pool,
4281 LPD3DXEFFECT* effect,
4282 LPD3DXBUFFER* compilation_errors)
4284 TRACE("(%p, %p, %u, %p, %p, %#x, %p, %p, %p): Forwarded to D3DXCreateEffectEx\n", device, srcdata, srcdatalen, defines,
4285 include, flags, pool, effect, compilation_errors);
4287 return D3DXCreateEffectEx(device, srcdata, srcdatalen, defines, include, NULL, flags, pool, effect, compilation_errors);
4290 static HRESULT d3dx9_effect_compiler_init(struct ID3DXEffectCompilerImpl *compiler, const char *data, SIZE_T data_size)
4292 HRESULT hr;
4293 struct ID3DXBaseEffectImpl *object = NULL;
4295 TRACE("effect %p, data %p, data_size %lu\n", compiler, data, data_size);
4297 compiler->ID3DXEffectCompiler_iface.lpVtbl = &ID3DXEffectCompiler_Vtbl;
4298 compiler->ref = 1;
4300 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4301 if (!object)
4303 ERR("Out of memory\n");
4304 hr = E_OUTOFMEMORY;
4305 goto err_out;
4308 hr = d3dx9_base_effect_init(object, data, data_size, NULL);
4309 if (hr != D3D_OK)
4311 FIXME("Failed to parse effect.\n");
4312 goto err_out;
4315 compiler->base_effect = &object->ID3DXBaseEffect_iface;
4317 return D3D_OK;
4319 err_out:
4321 HeapFree(GetProcessHeap(), 0, object);
4322 free_effect_compiler(compiler);
4324 return hr;
4327 HRESULT WINAPI D3DXCreateEffectCompiler(LPCSTR srcdata,
4328 UINT srcdatalen,
4329 CONST D3DXMACRO *defines,
4330 LPD3DXINCLUDE include,
4331 DWORD flags,
4332 LPD3DXEFFECTCOMPILER *compiler,
4333 LPD3DXBUFFER *parse_errors)
4335 struct ID3DXEffectCompilerImpl *object;
4336 HRESULT hr;
4338 TRACE("srcdata %p, srcdatalen %u, defines %p, include %p, flags %#x, compiler %p, parse_errors %p\n",
4339 srcdata, srcdatalen, defines, include, flags, compiler, parse_errors);
4341 if (!srcdata || !compiler)
4343 WARN("Invalid arguments supplied\n");
4344 return D3DERR_INVALIDCALL;
4347 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4348 if (!object)
4350 ERR("Out of memory\n");
4351 return E_OUTOFMEMORY;
4354 hr = d3dx9_effect_compiler_init(object, srcdata, srcdatalen);
4355 if (FAILED(hr))
4357 WARN("Failed to initialize effect compiler\n");
4358 HeapFree(GetProcessHeap(), 0, object);
4359 return hr;
4362 *compiler = &object->ID3DXEffectCompiler_iface;
4364 TRACE("Created ID3DXEffectCompiler %p\n", object);
4366 return D3D_OK;
4369 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl;
4371 struct ID3DXEffectPoolImpl
4373 ID3DXEffectPool ID3DXEffectPool_iface;
4374 LONG ref;
4377 static inline struct ID3DXEffectPoolImpl *impl_from_ID3DXEffectPool(ID3DXEffectPool *iface)
4379 return CONTAINING_RECORD(iface, struct ID3DXEffectPoolImpl, ID3DXEffectPool_iface);
4382 /*** IUnknown methods ***/
4383 static HRESULT WINAPI ID3DXEffectPoolImpl_QueryInterface(ID3DXEffectPool *iface, REFIID riid, void **object)
4385 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
4387 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), object);
4389 if (IsEqualGUID(riid, &IID_IUnknown) ||
4390 IsEqualGUID(riid, &IID_ID3DXEffectPool))
4392 This->ID3DXEffectPool_iface.lpVtbl->AddRef(iface);
4393 *object = This;
4394 return S_OK;
4397 WARN("Interface %s not found\n", debugstr_guid(riid));
4399 return E_NOINTERFACE;
4402 static ULONG WINAPI ID3DXEffectPoolImpl_AddRef(ID3DXEffectPool *iface)
4404 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
4406 TRACE("(%p)->(): AddRef from %u\n", This, This->ref);
4408 return InterlockedIncrement(&This->ref);
4411 static ULONG WINAPI ID3DXEffectPoolImpl_Release(ID3DXEffectPool *iface)
4413 struct ID3DXEffectPoolImpl *This = impl_from_ID3DXEffectPool(iface);
4414 ULONG ref = InterlockedDecrement(&This->ref);
4416 TRACE("(%p)->(): Release from %u\n", This, ref + 1);
4418 if (!ref)
4419 HeapFree(GetProcessHeap(), 0, This);
4421 return ref;
4424 static const struct ID3DXEffectPoolVtbl ID3DXEffectPool_Vtbl =
4426 /*** IUnknown methods ***/
4427 ID3DXEffectPoolImpl_QueryInterface,
4428 ID3DXEffectPoolImpl_AddRef,
4429 ID3DXEffectPoolImpl_Release
4432 HRESULT WINAPI D3DXCreateEffectPool(LPD3DXEFFECTPOOL *pool)
4434 struct ID3DXEffectPoolImpl *object;
4436 TRACE("(%p)\n", pool);
4438 if (!pool)
4439 return D3DERR_INVALIDCALL;
4441 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
4442 if (!object)
4444 ERR("Out of memory\n");
4445 return E_OUTOFMEMORY;
4448 object->ID3DXEffectPool_iface.lpVtbl = &ID3DXEffectPool_Vtbl;
4449 object->ref = 1;
4451 *pool = &object->ID3DXEffectPool_iface;
4453 return S_OK;
4456 HRESULT WINAPI D3DXCreateEffectFromFileExW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
4457 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
4458 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4460 LPVOID buffer;
4461 HRESULT ret;
4462 DWORD size;
4464 TRACE("(%s): relay\n", debugstr_w(srcfile));
4466 if (!device || !srcfile || !defines)
4467 return D3DERR_INVALIDCALL;
4469 ret = map_view_of_file(srcfile, &buffer, &size);
4471 if (FAILED(ret))
4472 return D3DXERR_INVALIDDATA;
4474 ret = D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
4475 UnmapViewOfFile(buffer);
4477 return ret;
4480 HRESULT WINAPI D3DXCreateEffectFromFileExA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
4481 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
4482 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4484 LPWSTR srcfileW;
4485 HRESULT ret;
4486 DWORD len;
4488 TRACE("(void): relay\n");
4490 if (!srcfile || !defines)
4491 return D3DERR_INVALIDCALL;
4493 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
4494 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
4495 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
4497 ret = D3DXCreateEffectFromFileExW(device, srcfileW, defines, include, skipconstants, flags, pool, effect, compilationerrors);
4498 HeapFree(GetProcessHeap(), 0, srcfileW);
4500 return ret;
4503 HRESULT WINAPI D3DXCreateEffectFromFileW(LPDIRECT3DDEVICE9 device, LPCWSTR srcfile,
4504 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
4505 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4507 TRACE("(void): relay\n");
4508 return D3DXCreateEffectFromFileExW(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
4511 HRESULT WINAPI D3DXCreateEffectFromFileA(LPDIRECT3DDEVICE9 device, LPCSTR srcfile,
4512 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
4513 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4515 TRACE("(void): relay\n");
4516 return D3DXCreateEffectFromFileExA(device, srcfile, defines, include, NULL, flags, pool, effect, compilationerrors);
4519 HRESULT WINAPI D3DXCreateEffectFromResourceExW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
4520 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
4521 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4523 HRSRC resinfo;
4525 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
4527 if (!device || !defines)
4528 return D3DERR_INVALIDCALL;
4530 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
4532 if (resinfo)
4534 LPVOID buffer;
4535 HRESULT ret;
4536 DWORD size;
4538 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
4540 if (FAILED(ret))
4541 return D3DXERR_INVALIDDATA;
4543 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
4546 return D3DXERR_INVALIDDATA;
4549 HRESULT WINAPI D3DXCreateEffectFromResourceExA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
4550 const D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR skipconstants, DWORD flags,
4551 LPD3DXEFFECTPOOL pool, LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4553 HRSRC resinfo;
4555 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
4557 if (!device || !defines)
4558 return D3DERR_INVALIDCALL;
4560 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
4562 if (resinfo)
4564 LPVOID buffer;
4565 HRESULT ret;
4566 DWORD size;
4568 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
4570 if (FAILED(ret))
4571 return D3DXERR_INVALIDDATA;
4573 return D3DXCreateEffectEx(device, buffer, size, defines, include, skipconstants, flags, pool, effect, compilationerrors);
4576 return D3DXERR_INVALIDDATA;
4579 HRESULT WINAPI D3DXCreateEffectFromResourceW(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCWSTR srcresource,
4580 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
4581 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4583 TRACE("(void): relay\n");
4584 return D3DXCreateEffectFromResourceExW(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
4587 HRESULT WINAPI D3DXCreateEffectFromResourceA(LPDIRECT3DDEVICE9 device, HMODULE srcmodule, LPCSTR srcresource,
4588 const D3DXMACRO *defines, LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTPOOL pool,
4589 LPD3DXEFFECT *effect, LPD3DXBUFFER *compilationerrors)
4591 TRACE("(void): relay\n");
4592 return D3DXCreateEffectFromResourceExA(device, srcmodule, srcresource, defines, include, NULL, flags, pool, effect, compilationerrors);
4595 HRESULT WINAPI D3DXCreateEffectCompilerFromFileW(LPCWSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
4596 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
4598 LPVOID buffer;
4599 HRESULT ret;
4600 DWORD size;
4602 TRACE("(%s): relay\n", debugstr_w(srcfile));
4604 if (!srcfile || !defines)
4605 return D3DERR_INVALIDCALL;
4607 ret = map_view_of_file(srcfile, &buffer, &size);
4609 if (FAILED(ret))
4610 return D3DXERR_INVALIDDATA;
4612 ret = D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
4613 UnmapViewOfFile(buffer);
4615 return ret;
4618 HRESULT WINAPI D3DXCreateEffectCompilerFromFileA(LPCSTR srcfile, const D3DXMACRO *defines, LPD3DXINCLUDE include,
4619 DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
4621 LPWSTR srcfileW;
4622 HRESULT ret;
4623 DWORD len;
4625 TRACE("(void): relay\n");
4627 if (!srcfile || !defines)
4628 return D3DERR_INVALIDCALL;
4630 len = MultiByteToWideChar(CP_ACP, 0, srcfile, -1, NULL, 0);
4631 srcfileW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*srcfileW));
4632 MultiByteToWideChar(CP_ACP, 0, srcfile, -1, srcfileW, len);
4634 ret = D3DXCreateEffectCompilerFromFileW(srcfileW, defines, include, flags, effectcompiler, parseerrors);
4635 HeapFree(GetProcessHeap(), 0, srcfileW);
4637 return ret;
4640 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceA(HMODULE srcmodule, LPCSTR srcresource, const D3DXMACRO *defines,
4641 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
4643 HRSRC resinfo;
4645 TRACE("(%p, %s): relay\n", srcmodule, debugstr_a(srcresource));
4647 resinfo = FindResourceA(srcmodule, srcresource, (LPCSTR) RT_RCDATA);
4649 if (resinfo)
4651 LPVOID buffer;
4652 HRESULT ret;
4653 DWORD size;
4655 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
4657 if (FAILED(ret))
4658 return D3DXERR_INVALIDDATA;
4660 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
4663 return D3DXERR_INVALIDDATA;
4666 HRESULT WINAPI D3DXCreateEffectCompilerFromResourceW(HMODULE srcmodule, LPCWSTR srcresource, const D3DXMACRO *defines,
4667 LPD3DXINCLUDE include, DWORD flags, LPD3DXEFFECTCOMPILER *effectcompiler, LPD3DXBUFFER *parseerrors)
4669 HRSRC resinfo;
4671 TRACE("(%p, %s): relay\n", srcmodule, debugstr_w(srcresource));
4673 resinfo = FindResourceW(srcmodule, srcresource, (LPCWSTR) RT_RCDATA);
4675 if (resinfo)
4677 LPVOID buffer;
4678 HRESULT ret;
4679 DWORD size;
4681 ret = load_resource_into_memory(srcmodule, resinfo, &buffer, &size);
4683 if (FAILED(ret))
4684 return D3DXERR_INVALIDDATA;
4686 return D3DXCreateEffectCompiler(buffer, size, defines, include, flags, effectcompiler, parseerrors);
4689 return D3DXERR_INVALIDDATA;